本帖最后由 我只是个野指针 于 2023-12-11 17:19 编辑
【瑞萨RA6E1】+瑞萨资料分享与RASC的MDK模板生成
我以前应用过中微半导体的BAT系列的MCU,以前就听说中微和瑞萨的MCU比较像,通过这次了解的确两种之间有很多相似的地方,但是瑞萨的MCU的资料和MCU的型号,
比中微的可就丰富多了,中微的BAT系列MCU只要安装一下MDK和pack,他的环境和资料,就安装完成了,瑞萨就复杂多了,就IDE,瑞萨有自己的IDE,还支持MDK IAR,此贴和大家分享一下瑞萨MCU的下载方法和RASC的MDK的使用。
很多人分享了在瑞萨官网下载资料的方法,但是国内访问外网并不是很友好,瑞萨的中国团队创办了一个社区网站
网站网址如下:
2.1 瑞萨IDE 及RASC下载
进入RA生态社区论坛好点击资料下载 然后点击工具就会看到如下图的资料了。
里面是百度网盘资料的链接开通会员之后还是很快的,相关版本的软件都有
在往下拉还能找到这个开发板的资料包。
安装RASC
RA Smart Configurator是瑞萨的
智
能配置软件,在配置完成后,可以生成keil工程,方便使用keil的用户进行开发。
在
RA生态社区论坛下载好
RA Smart Configurator
即可安装,
1. 首先依然是环境扫描和协议告知,依次点击“Next”、勾选“I accept……”后点击
“Next”:
2. 随后设置在开始菜单中的安装组,默认就好,然后点击“Install”开始安装,等待进
度条执行完后就安装完成了:
安装完成,点击“OK”结束安装:
其实也就是一路“Next”就好了
4、keil模板生成
4. 1 打开运行RASC
4.2 如图 输入各项参数
4. 3选择开发包版本和芯片 这里可以直接选择瑞萨的官方开发板FPB-RA6E1
4. 4如上图设置
4. 5如上图设置
4. 6 选择第一个
4. 7创建完成后得到如下的界面,点击“Summary”项中“Location”处最右端的跳转图标可以打开工程所在文件夹
4. 8
4.
9
4. 10 添加下载算法
OK!
5、简单看下代码
5.1 Main文件
1./* generated main source file - do not edit */
2.#include "hal_data.h"
3. int main(void) {
4. hal_entry();
5. return 0;
6. }复制代码main函数调用了hal_entry(); 函数
5.2 hal_entry函数
1./*******************************************************************************************************************//**
2. * @brief Blinky example application
3. *
4. * Blinks all leds at a rate of 1 second using the software delay function provided by the BSP.
5. *
6. **********************************************************************************************************************/
7.void hal_entry (void)
8.{
9.#if BSP_TZ_SECURE_BUILD
10.
11. /* Enter non-secure code */
12. R_BSP_NonSecureEnter();
13.#endif
14.
15. /* Define the units to be used with the software delay function */
16. const bsp_delay_units_t bsp_delay_units = BSP_DELAY_UNITS_MILLISECONDS;
17.
18. /* Set the blink frequency (must be <= bsp_delay_units */
19. const uint32_t freq_in_hz = 2;
20.
21. /* Calculate the delay in terms of bsp_delay_units */
22. const uint32_t delay = bsp_delay_units / freq_in_hz;
23.
24. /* LED type structure */
25. bsp_leds_t leds = g_bsp_leds;
26.
27. /* If this board has no LEDs then trap here */
28. if (0 == leds.led_count)
29. {
30. while (1)
31. {
32. ; // There are no LEDs on this board
33. }
34. }
35.
36. /* Holds level to set for pins */
37. bsp_io_level_t pin_level = BSP_IO_LEVEL_LOW;
38.
39. while (1)
40. {
41. /* Enable access to the PFS registers. If using r_ioport module then register protection is automatically
42. * handled. This code uses BSP IO functions to show how it is used.
43. */
44. R_BSP_PinAccessEnable();
45.
46. /* Update all board LEDs */
47. for (uint32_t i = 0; i < leds.led_count; i++)
48. {
49. /* Get pin to toggle */
50. uint32_t pin = leds.p_leds[i];
51.
52. /* Write to this pin */
53. R_BSP_PinWrite((bsp_io_port_pin_t) pin, pin_level);
54. }
55.
56. /* Protect PFS registers */
57. R_BSP_PinAccessDisable();
58.
59. /* Toggle level for next write */
60. if (BSP_IO_LEVEL_LOW == pin_level)
61. {
62. pin_level = BSP_IO_LEVEL_HIGH;
63. }
64. else
65. {
66. pin_level = BSP_IO_LEVEL_LOW;
67. }
68.
69. /* Delay */
70. R_BSP_SoftwareDelay(delay, bsp_delay_units);
71. }
72.}复制代码这个闪灯真的复杂啊
先看这行代码
bsp_leds_t leds = g_bsp_leds;
这里将g_bsp_leds 赋值给leds,g_bsp_leds 实现如下
const bsp_leds_t g_bsp_leds =
{
.led_count = (uint16_t) ((sizeof(g_bsp_prv_leds) / sizeof(g_bsp_prv_leds[0]))),
.p_leds = &g_bsp_prv_leds[0]
};
g_bsp_prv_leds定义了两个LED
/** Array of LED IOPORT pins. */
static const uint16_t g_bsp_prv_leds[] =
{
(uint16_t) BSP_IO_PORT_04_PIN_08, ///< LED1
(uint16_t) BSP_IO_PORT_04_PIN_07, ///< LED2
};
然后通过这个for 输出GPIO电平
46. /* Update all board LEDs */
47. for (uint32_t i = 0; i < leds.led_count; i++)
48. {
49. /* Get pin to toggle */
50. uint32_t pin = leds.p_leds[i];
51.
52. /* Write to this pin */
53. R_BSP_PinWrite((bsp_io_port_pin_t) pin, pin_level);
54. }复制代码
通过判断pin_level来改GPIO输出
if (BSP_IO_LEVEL_LOW == pin_level)
{
pin_level = BSP_IO_LEVEL_HIGH;
}
else
{
pin_level = BSP_IO_LEVEL_LOW;
}
复制代码
下载验证