[MCU] 瑞萨RA4M2开发板评测-循环LED控制

[复制链接]
 楼主| lrj2024 发表于 2025-5-29 17:06 | 显示全部楼层 |阅读模式
本次参加瑞萨活动,非常荣幸获得瑞萨RA4M2开发板一块。
如下图所示:







本开发板资源丰富,如下介绍。
特性:
1个复位按键
2个用户按键
2个触摸按键
3个LED
2个PMOD接口
板载USB转TTL模块,可用于串口通信和烧录
板载SWD接口,方便用户调试与下载
支持 TrustZone 的 100MHz Arm Cortex-M33
安全芯片的功能
512kB 闪存、64kB SRAM(支持奇偶校验)以及 64kB ECC SRAM
8KB 数据闪存,提供与 EEPROM 类似的数据存储功能
1kB 休眠用 SRAM
100 引脚封装
电容式触摸传感单元 (CTSU)
全速 USB 2.0,支持主机模式和设备模式
CAN 2.0B
四线 SPI
SCI(UART、简单 SPI、简单 I2C)
独立SPI/I2C 多主接口
SDHI 和 MMC




对我而言,首次接触,所以要好好学习一下。
本次实现LED驱动。
效果如下所示:


开发环境:
采用e2stduio。管脚分配采用 FSP
代码编译成功,会生成文件。



实现代码如下:



  1. #include "hal_data.h"

  2. FSP_CPP_HEADER
  3. void R_BSP_WarmStart(bsp_warm_start_event_t event);
  4. FSP_CPP_FOOTER

  5. /*******************************************************************************************************************//**
  6. * main() is generated by the RA Configuration editor and is used to generate threads if an RTOS is used.  This function
  7. * is called by main() when no RTOS is used.
  8. **********************************************************************************************************************/
  9. void hal_entry(void)
  10. {
  11.     /* TODO: add your own code here */

  12.     while(1)
  13.     {

  14. //              R_IOPORT_PinWrite(&g_ioport_ctrl, BSP_IO_PORT_04_PIN_04, BSP_IO_LEVEL_LOW);
  15. //              R_IOPORT_PinWrite(&g_ioport_ctrl, BSP_IO_PORT_04_PIN_05, BSP_IO_LEVEL_LOW);
  16. //              R_BSP_SoftwareDelay(500, BSP_DELAY_UNITS_MILLISECONDS);
  17. //
  18. //              R_IOPORT_PinWrite(&g_ioport_ctrl, BSP_IO_PORT_04_PIN_04, BSP_IO_LEVEL_HIGH);
  19. //              R_IOPORT_PinWrite(&g_ioport_ctrl, BSP_IO_PORT_04_PIN_05, BSP_IO_LEVEL_HIGH);
  20. //              R_BSP_SoftwareDelay(500, BSP_DELAY_UNITS_MILLISECONDS);


  21.        R_IOPORT_PinWrite(&g_ioport_ctrl, BSP_IO_PORT_00_PIN_02, BSP_IO_LEVEL_LOW);
  22.        R_IOPORT_PinWrite(&g_ioport_ctrl, BSP_IO_PORT_04_PIN_04, BSP_IO_LEVEL_LOW);
  23.        R_IOPORT_PinWrite(&g_ioport_ctrl, BSP_IO_PORT_04_PIN_05, BSP_IO_LEVEL_HIGH);
  24.        R_BSP_SoftwareDelay(500, BSP_DELAY_UNITS_MILLISECONDS);

  25.        R_IOPORT_PinWrite(&g_ioport_ctrl, BSP_IO_PORT_04_PIN_04, BSP_IO_LEVEL_HIGH);
  26.        R_IOPORT_PinWrite(&g_ioport_ctrl, BSP_IO_PORT_04_PIN_05, BSP_IO_LEVEL_LOW);
  27.        R_IOPORT_PinWrite(&g_ioport_ctrl, BSP_IO_PORT_00_PIN_02, BSP_IO_LEVEL_LOW);
  28.        R_BSP_SoftwareDelay(500, BSP_DELAY_UNITS_MILLISECONDS);

  29.        R_IOPORT_PinWrite(&g_ioport_ctrl, BSP_IO_PORT_04_PIN_04, BSP_IO_LEVEL_LOW);
  30.        R_IOPORT_PinWrite(&g_ioport_ctrl, BSP_IO_PORT_04_PIN_05, BSP_IO_LEVEL_LOW);
  31.        R_IOPORT_PinWrite(&g_ioport_ctrl, BSP_IO_PORT_00_PIN_02, BSP_IO_LEVEL_HIGH);
  32.        R_BSP_SoftwareDelay(500, BSP_DELAY_UNITS_MILLISECONDS);

  33.        R_IOPORT_PinWrite(&g_ioport_ctrl, BSP_IO_PORT_04_PIN_04, BSP_IO_LEVEL_HIGH);
  34.        R_IOPORT_PinWrite(&g_ioport_ctrl, BSP_IO_PORT_04_PIN_05, BSP_IO_LEVEL_HIGH);
  35.        R_IOPORT_PinWrite(&g_ioport_ctrl, BSP_IO_PORT_00_PIN_02, BSP_IO_LEVEL_HIGH);
  36.        R_BSP_SoftwareDelay(500, BSP_DELAY_UNITS_MILLISECONDS);

  37.     }
  38. #if BSP_TZ_SECURE_BUILD
  39.     /* Enter non-secure code */
  40.     R_BSP_NonSecureEnter();
  41. #endif
  42. }

  43. /*******************************************************************************************************************//**
  44. * This function is called at various points during the startup process.  This implementation uses the event that is
  45. * called right before main() to set up the pins.
  46. *
  47. * @param[in]  event    Where at in the start up process the code is currently at
  48. **********************************************************************************************************************/
  49. void R_BSP_WarmStart(bsp_warm_start_event_t event)
  50. {
  51.     if (BSP_WARM_START_RESET == event)
  52.     {
  53. #if BSP_FEATURE_FLASH_LP_VERSION != 0

  54.         /* Enable reading from data flash. */
  55.         R_FACI_LP->DFLCTL = 1U;

  56.         /* Would normally have to wait tDSTOP(6us) for data flash recovery. Placing the enable here, before clock and
  57.          * C runtime initialization, should negate the need for a delay since the initialization will typically take more than 6us. */
  58. #endif
  59.     }

  60.     if (BSP_WARM_START_POST_C == event)
  61.     {
  62.         /* C runtime environment and system clocks are setup. */

  63.         /* Configure pins. */
  64.         R_IOPORT_Open (&g_ioport_ctrl, g_ioport.p_cfg);
  65.     }
  66. }

  67. #if BSP_TZ_SECURE_BUILD

  68. BSP_CMSE_NONSECURE_ENTRY void template_nonsecure_callable ();

  69. /* Trustzone Secure Projects require at least one nonsecure callable function in order to build (Remove this if it is not required to build). */
  70. BSP_CMSE_NONSECURE_ENTRY void template_nonsecure_callable ()
  71. {

  72. }
  73. #endif


下载成功提示如下:
这里采用RFP下载程序。
jilink-OB下载器连接。


实现效果如下:







本帖子中包含更多资源

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

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

本版积分规则

5

主题

22

帖子

0

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