本帖最后由 meiyaolei 于 2024-7-9 20:05 编辑
下面正式开始,分享一下我的步骤和计划:
1、步骤
打开软件ModusToolbox,创建一个新的工程。在工程创建向导中,选择合适的芯片型号(CYW20829)。
编写代码:
在工程的源代码文件中,找到打印字符串的代码部分。将默认的打印字符串修改为“Hello 21ic, Hello Infineon CYW20829”。
编译与下载
编译代码:
使用ModusToolbox的编译功能,对修改后的代码进行编译。确保编译过程中没有错误和警告。
下载代码:
将编译好的代码下载到CYW20829开发板上。通常通过USB接口和KitProg3编程器完成。
串口调试
连接串口调试工具:
使用串口调试工具(PuTTY、Tera Term等)连接到开发板的串口。确保选择正确的COM口和波特率。
查看输出:
在串口调试工具中,按下开发板上的复位按钮,使开发板重新上电运行。此时,应该能够在串口调试工具的窗口中看到“Hello 21ic, Hello Infineon CYW20829”的打印信息。
2、代码:
- #include "cyhal.h"
- #include "cybsp.h"
- #include "cy_retarget_io.h"
- void handle_error(void)
- {
- /* Disable all interrupts. */
- __disable_irq();
- CY_ASSERT(0);
- }
- int main(void)
- {
- cy_rslt_t result;
- #if defined(CY_DEVICE_SECURE)
- cyhal_wdt_t wdt_obj;
- /* Clear watchdog timer so that it doesn't trigger a reset */
- result = cyhal_wdt_init(&wdt_obj, cyhal_wdt_get_max_timeout_ms());
- CY_ASSERT(CY_RSLT_SUCCESS == result);
- cyhal_wdt_free(&wdt_obj);
- #endif
- uint8_t read_data; /* Variable to store the received character
- * through terminal */
- /* Initialize the device and board peripherals */
- result = cybsp_init();
- if (result != CY_RSLT_SUCCESS)
- {
- handle_error();
- }
- /* Initialize retarget-io to use the debug UART port */
- result = cy_retarget_io_init_fc(CYBSP_DEBUG_UART_TX,
- CYBSP_DEBUG_UART_RX,
- CYBSP_DEBUG_UART_CTS,
- CYBSP_DEBUG_UART_RTS,
- CY_RETARGET_IO_BAUDRATE);
- if (result != CY_RSLT_SUCCESS)
- {
- handle_error();
- }
- /* \x1b[2J\x1b[;H - ANSI ESC sequence for clear screen Hello 21ic, Hello Infineon CYW20829 */
- //printf("\x1b[2J\x1b[;H");
- printf("Hello 21ic, Hello Infineon CYW20829 \r\n");
- printf("***********************************************************\r\n");
- __enable_irq();
-
- for (;;)
- {
- if (CY_RSLT_SUCCESS == cyhal_uart_getc(&cy_retarget_io_uart_obj,
- &read_data, 0))
- {
- if (CY_RSLT_SUCCESS != cyhal_uart_putc(&cy_retarget_io_uart_obj,
- read_data))
- {
- handle_error();
- }
- }
- else
- {
- handle_error();
- }
- }
- }
- /* [] END OF FILE */
3、输出结果:
4、具体步骤:
打开软件,装好相应的东西后,就会出如这个界面:
这里点launch就可以了。
然后打开相关的软件或者示例编译,再下载:
打开串口助手的软件,再按板子上的复位,可以在串口助手中看到打印出来的结果Hello 21ic, Hello Infineon CYW20829。
|