[通用 MCU] 【英飞凌CYW20829测评】利用串口显示Hello 21ic, Hello Infineon CYW20829

[复制链接]
763|0
 楼主| meiyaolei 发表于 2024-7-9 19:12 | 显示全部楼层 |阅读模式
本帖最后由 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、代码:
  1. #include "cyhal.h"
  2. #include "cybsp.h"
  3. #include "cy_retarget_io.h"


  4. void handle_error(void)
  5. {
  6.      /* Disable all interrupts. */
  7.     __disable_irq();

  8.     CY_ASSERT(0);
  9. }

  10. int main(void)
  11. {
  12.     cy_rslt_t result;
  13.     #if defined(CY_DEVICE_SECURE)
  14.         cyhal_wdt_t wdt_obj;
  15.         /* Clear watchdog timer so that it doesn't trigger a reset */
  16.         result = cyhal_wdt_init(&wdt_obj, cyhal_wdt_get_max_timeout_ms());
  17.         CY_ASSERT(CY_RSLT_SUCCESS == result);
  18.         cyhal_wdt_free(&wdt_obj);
  19.     #endif

  20.     uint8_t read_data; /* Variable to store the received character
  21.                         * through terminal */

  22.     /* Initialize the device and board peripherals */
  23.     result = cybsp_init();
  24.     if (result != CY_RSLT_SUCCESS)
  25.     {
  26.         handle_error();
  27.     }

  28.     /* Initialize retarget-io to use the debug UART port */

  29.     result = cy_retarget_io_init_fc(CYBSP_DEBUG_UART_TX,
  30.                                     CYBSP_DEBUG_UART_RX,
  31.                                     CYBSP_DEBUG_UART_CTS,
  32.                                     CYBSP_DEBUG_UART_RTS,
  33.                                     CY_RETARGET_IO_BAUDRATE);

  34. if (result != CY_RSLT_SUCCESS)
  35.     {
  36.         handle_error();
  37.     }

  38.     /* \x1b[2J\x1b[;H - ANSI ESC sequence for clear screen  Hello 21ic, Hello Infineon CYW20829 */
  39.     //printf("\x1b[2J\x1b[;H");
  40.     printf("Hello 21ic, Hello Infineon CYW20829 \r\n");
  41.     printf("***********************************************************\r\n");

  42.     __enable_irq();

  43.     for (;;)
  44.     {
  45.         if (CY_RSLT_SUCCESS == cyhal_uart_getc(&cy_retarget_io_uart_obj,
  46.                                                &read_data, 0))
  47.         {
  48.             if (CY_RSLT_SUCCESS != cyhal_uart_putc(&cy_retarget_io_uart_obj,
  49.                                                    read_data))
  50.             {
  51.                 handle_error();
  52.             }
  53.         }
  54.         else
  55.         {
  56.             handle_error();
  57.         }
  58.     }
  59. }

  60. /* [] END OF FILE */
3、输出结果:

4、具体步骤:
打开软件,装好相应的东西后,就会出如这个界面:

这里点launch就可以了。


然后打开相关的软件或者示例编译,再下载:

打开串口助手的软件,再按板子上的复位,可以在串口助手中看到打印出来的结果Hello 21ic, Hello Infineon CYW20829。




本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?注册

×
您需要登录后才可以回帖 登录 | 注册

本版积分规则

认证:工程师
简介:超越自我,为设计激发灵感和想象。

263

主题

836

帖子

6

粉丝
快速回复 在线客服 返回列表 返回顶部