打印
[MCU]

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

[复制链接]
109|0
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
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
代码编译成功,会生成文件。



实现代码如下:



#include "hal_data.h"

FSP_CPP_HEADER
void R_BSP_WarmStart(bsp_warm_start_event_t event);
FSP_CPP_FOOTER

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

    while(1)
    {

//              R_IOPORT_PinWrite(&g_ioport_ctrl, BSP_IO_PORT_04_PIN_04, BSP_IO_LEVEL_LOW);
//              R_IOPORT_PinWrite(&g_ioport_ctrl, BSP_IO_PORT_04_PIN_05, BSP_IO_LEVEL_LOW);
//              R_BSP_SoftwareDelay(500, BSP_DELAY_UNITS_MILLISECONDS);
//
//              R_IOPORT_PinWrite(&g_ioport_ctrl, BSP_IO_PORT_04_PIN_04, BSP_IO_LEVEL_HIGH);
//              R_IOPORT_PinWrite(&g_ioport_ctrl, BSP_IO_PORT_04_PIN_05, BSP_IO_LEVEL_HIGH);
//              R_BSP_SoftwareDelay(500, BSP_DELAY_UNITS_MILLISECONDS);


       R_IOPORT_PinWrite(&g_ioport_ctrl, BSP_IO_PORT_00_PIN_02, BSP_IO_LEVEL_LOW);
       R_IOPORT_PinWrite(&g_ioport_ctrl, BSP_IO_PORT_04_PIN_04, BSP_IO_LEVEL_LOW);
       R_IOPORT_PinWrite(&g_ioport_ctrl, BSP_IO_PORT_04_PIN_05, BSP_IO_LEVEL_HIGH);
       R_BSP_SoftwareDelay(500, BSP_DELAY_UNITS_MILLISECONDS);

       R_IOPORT_PinWrite(&g_ioport_ctrl, BSP_IO_PORT_04_PIN_04, BSP_IO_LEVEL_HIGH);
       R_IOPORT_PinWrite(&g_ioport_ctrl, BSP_IO_PORT_04_PIN_05, BSP_IO_LEVEL_LOW);
       R_IOPORT_PinWrite(&g_ioport_ctrl, BSP_IO_PORT_00_PIN_02, BSP_IO_LEVEL_LOW);
       R_BSP_SoftwareDelay(500, BSP_DELAY_UNITS_MILLISECONDS);

       R_IOPORT_PinWrite(&g_ioport_ctrl, BSP_IO_PORT_04_PIN_04, BSP_IO_LEVEL_LOW);
       R_IOPORT_PinWrite(&g_ioport_ctrl, BSP_IO_PORT_04_PIN_05, BSP_IO_LEVEL_LOW);
       R_IOPORT_PinWrite(&g_ioport_ctrl, BSP_IO_PORT_00_PIN_02, BSP_IO_LEVEL_HIGH);
       R_BSP_SoftwareDelay(500, BSP_DELAY_UNITS_MILLISECONDS);

       R_IOPORT_PinWrite(&g_ioport_ctrl, BSP_IO_PORT_04_PIN_04, BSP_IO_LEVEL_HIGH);
       R_IOPORT_PinWrite(&g_ioport_ctrl, BSP_IO_PORT_04_PIN_05, BSP_IO_LEVEL_HIGH);
       R_IOPORT_PinWrite(&g_ioport_ctrl, BSP_IO_PORT_00_PIN_02, BSP_IO_LEVEL_HIGH);
       R_BSP_SoftwareDelay(500, BSP_DELAY_UNITS_MILLISECONDS);

    }
#if BSP_TZ_SECURE_BUILD
    /* Enter non-secure code */
    R_BSP_NonSecureEnter();
#endif
}

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

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

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

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

        /* Configure pins. */
        R_IOPORT_Open (&g_ioport_ctrl, g_ioport.p_cfg);
    }
}

#if BSP_TZ_SECURE_BUILD

BSP_CMSE_NONSECURE_ENTRY void template_nonsecure_callable ();

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

}
#endif


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


实现效果如下:







使用特权

评论回复

相关帖子

发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

4

主题

19

帖子

0

粉丝