很荣幸获得这次由电子发烧友举办的RA0E1开发板试用机会。
这是我第一次接触瑞萨的MCU。此前仅用过MSP430以及STM32的MCU。

收到板子看起来很精致小巧,不过美中不足的是不自带仿真器,仅仅一个USB转串口(CH340)。
那么问题来了,瑞萨有类似STM32的程序下载工具吗?(STM32CubeProgrammer)通过USB或者串口下载。
好在我有一台J-Link V9,是看到了特别说明:
特别说明:需要有调试器 E2 Lite、e2 cube、 Jlink V9****以上(可用于M23内核),否则可能无法完成试用。
首先搭载开发环境,由于没用过瑞萨的MCU,第一时间搜索了下,瑞萨的IDE是e2 studio。
连忙上瑞萨官网下载e2 studio,这直接导致我由于不了解瑞萨而踩了第一个坑。

下载下来默认安装完毕,新建项目,悲剧来了,提示
No FSP versions installed.

查了下FSP:
瑞萨电子灵活配置软件包 (FSP)
是用于嵌入式系统设计的高质量增强型软件包,支持瑞萨电子 RA 产品家族 Arm 微控制器,提供用户友好的界面且可灵活扩展,确保从入门级到高性能的整个 RA 微控制器的开发。
FSP 旨在以较低的内存占用量提供快速高效的驱动程序和协议栈。 FSP 集成了中间件协议栈、独立于 RTOS 的硬件抽象层(HAL)驱动程序, 以及最基础的板级支持包(BSP)驱动程序。FSP 还支持
FreeRTOS™ 实时操作系统(RTOS)。
原来FSP是类似STM32 HAL库的东西,只下载了IDE还不行啊,还得下载FSP。
问题又来了,既然已经安装e2 studio,那我单独下载FSP 总可以吧。

然而,单独下载FSP的链接是个基于GitHub的链接,下载速度50kb/s,还会无故中断,坑坑死个人。
折腾好久也没搞成。

最后发现,还不如下载 已经集成了FSP的e2 studio ,也就是setup_fsp_v5_4_0_e2s_v2024-04.exe.
这个下载链接是基于瑞萨官网的,速度还可以。
https://www2.info.renesas.cn/fsp?os=windows&ins=e2s

卸载之前安装的,重新安装再新建工程就一切正常了。


选择:J-link下载
图形化设置界面跟ST的STM32CubeMX如出一辙,但看起来分类没有STM32CubeMX清晰。

根据电路图,把P103和P112设置为普通IO口,并设置为输出。


在hal_entry.c函数中插入以下代码(基于HAL库,跟 STM32 的HAL非常相似)
void
hal_entry(void)
{
while(1)
{
R_IOPORT_PinWrite(&g_ioport_ctrl, BSP_IO_PORT_01_PIN_12, BSP_IO_LEVEL_LOW);
R_IOPORT_PinWrite(&g_ioport_ctrl, BSP_IO_PORT_01_PIN_03,
BSP_IO_LEVEL_HIGH);
R_BSP_SoftwareDelay(1000, BSP_DELAY_UNITS_MILLISECONDS);
R_IOPORT_PinWrite(&g_ioport_ctrl, BSP_IO_PORT_01_PIN_12,
BSP_IO_LEVEL_HIGH);
R_IOPORT_PinWrite(&g_ioport_ctrl, BSP_IO_PORT_01_PIN_03, BSP_IO_LEVEL_LOW);
R_BSP_SoftwareDelay(1000, BSP_DELAY_UNITS_MILLISECONDS);
}
#if BSP_TZ_SECURE_BUILD
R_BSP_NonSecureEnter();
#endif
}
最后就是编译及下载,一切正常。
