【瑞萨RA-eco-RA6M4评测】环境搭建与LED灯驱动
开发板收到有段时间,承蒙管管抬爱,侥幸获得此次瑞萨RA6M4开发板的评测,其实平时很少接触瑞萨的方案,加之工作又比较忙,因此只能抽时间研究研究。此次与大伙分享一下初级入门篇,没错,简单运用瑞萨提供的fsp灵活配置工具,构建基于业内单片朋友比较熟悉的keil开发工程。首先我们通过github地址链接https://github.com/renesas/fsp/releases下载FSP的最新v6.5.1版本的FSP软件安装包,再者需要在该网页中下载“MDK_Device_Packs_v6.5.1.zip”文件。
安装FSP,建议首先将杀毒软件暂时关闭,选择一个不含中文字符的目录,进行勾选式安装。
安装pack支持包,将“MDK_Device_Packs_v6.5.1.zip”文件解压,双击安装此pack支持包,默认目录即可。
完成了上述的软件工具安装后,直接打开“Renesas\RA\sc_v2026-04.2_fsp_v6.5.0\eclipse”目录下的“rasc.exe”应用程序,然后构建一份基于该款开发板的基本工程框架,这里尤其值得注意的是,该型号板卡存在两个版本,本人拿到的是基于RA6M4 v2.0版本,两个版本硬件上存有差异。
这里需要注意的是板上采用了12MHz的外部晶振,因此需要手动将时钟树更改一下。
然后根据瑞萨官方提供的硬件电路原理图,找到LED部分的,如下图所示,在FSP中快速配置P002,P404,P405三个管脚位设为输出模式。
然后点击右上角的“生成当前的工程内容”,则会导出符合Keil的可编译工程。
再手动添加一些对LED灯逻辑控制的应用代码。
hal_entry.c
#include "hal_data.h"
#include "r_ioport.h"
#define LED1_PORT BSP_IO_PORT_00_PIN_02
#define LED2_PORT BSP_IO_PORT_04_PIN_04
#define LED3_PORT BSP_IO_PORT_04_PIN_05
#define led1_on()R_IOPORT_PinWrite(&g_ioport_ctrl, LED1_PORT, BSP_IO_LEVEL_HIGH)
#define led2_on()R_IOPORT_PinWrite(&g_ioport_ctrl, LED2_PORT, BSP_IO_LEVEL_HIGH)
#define led3_on()R_IOPORT_PinWrite(&g_ioport_ctrl, LED3_PORT, BSP_IO_LEVEL_HIGH)
#define led1_off()R_IOPORT_PinWrite(&g_ioport_ctrl, LED1_PORT, BSP_IO_LEVEL_LOW)
#define led2_off()R_IOPORT_PinWrite(&g_ioport_ctrl, LED2_PORT, BSP_IO_LEVEL_LOW)
#define led3_off()R_IOPORT_PinWrite(&g_ioport_ctrl, LED3_PORT, BSP_IO_LEVEL_LOW)
void init_led(void)
{
led1_off();
led2_off();
led3_off();
}
void delay_ms(uint32_t ms)
{
R_BSP_SoftwareDelay(ms, BSP_DELAY_UNITS_MILLISECONDS);
}
#if (1 == BSP_MULTICORE_PROJECT) && BSP_TZ_SECURE_BUILD
bsp_ipc_semaphore_handle_t g_core_start_semaphore =
{
.semaphore_num = 0
};
#endif
/*******************************************************************************************************************//**
* 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 */
init_led();
while(1)
{
delay_ms(250);
led1_on();
led2_off();
led3_off();
delay_ms(250);
led1_off();
led2_on();
led3_off();
delay_ms(250);
led1_off();
led2_off();
led3_on();
delay_ms(250);
led1_off();
led2_on();
led3_off();
delay_ms(250);
led1_on();
led2_off();
led3_off();
for (int num = 0; num < 3; num++)
{
delay_ms(200);
led1_on();
led2_on();
led3_on();
delay_ms(200);
led1_off();
led2_off();
led3_off();
}
}
/* Wake up 2nd core if this is first core and we are inside a multicore project. */
#if (0 == _RA_CORE) && (1 == BSP_MULTICORE_PROJECT) && !BSP_TZ_NONSECURE_BUILD
#if BSP_TZ_SECURE_BUILD
/* Take semaphore so 2nd core can clear it */
R_BSP_IpcSemaphoreTake(&g_core_start_semaphore);
#endif
R_BSP_SecondaryCoreStart();
#if BSP_TZ_SECURE_BUILD
/* Wait for 2nd core to start and clear semaphore */
while(FSP_ERR_IN_USE == R_BSP_IpcSemaphoreTake(&g_core_start_semaphore))
{
;
}
#endif
#endif
#if (1 == _RA_CORE) && (1 == BSP_MULTICORE_PROJECT) && BSP_TZ_SECURE_BUILD
/* Signal to 1st core that 2nd core has started */
R_BSP_IpcSemaphoreGive(&g_core_start_semaphore);
#endif
#if BSP_TZ_SECURE_BUILD
/* Enter non-secure code */
R_BSP_NonSecureEnter();
#endif
}
#if BSP_TZ_SECURE_BUILD
FSP_CPP_HEADER
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 ()
{
}
FSP_CPP_FOOTER
#endif
代码如上完善好后,编译ok,接下来介绍一下关于程序下载。这里需要注意MODE1字样的插针连接方式,该板卡支持USB BOOT与内部Flash工作模式,这里我们需要将程序更新到内部Flash,因此将跳线帽竖向连接,板上的丝印也有示意图,非常清楚明了。
使用JLink下载,选择下载的算法如下,并勾选更新程序后自动重启开发板。
最终的点灯程序效果展示如下:
页:
[1]