本次主要基于RASC实现一个串口demo。
一、硬件介绍
瑞萨的SCI(Serial Communications Interface),是一个概念,包括串口、IIC、SPI等总线。
The Serial Communications Interface (SCI) × 6 channels have asynchronous and synchronous serial interfaces:
● Asynchronous interfaces (UART and Asynchronous Communications Interface Adapter (ACIA))
● 8-bit clock synchronous interface
● Simple IIC (master-only)
● Simple SPI
● Smart card interface
● Manchester interface
● Extended Serial interface
The smart card interface complies with the ISO/IEC 7816-3 standard for electronic signals and transmission protocol. SCIn
(n = 0, 3, 4, 9) has FIFO buffers to enable continuous and full-dup
此次使用到的是USART9,即P109和P110,分别为RX和TX。
二、配置
打开RASC之后,Pins里面找到Peripherals,在Connectivity中找到SCI的分类,选择SCI9。
Operation Mode记得一定要选择成asynchronous UART,然后点箭头号进去继续配置每个Pin。
Pins设置好后,到Stacks中新建一个stack:
最后这样:
选择重新生成工程,MDK打开之。
三、代码
修改的不错,UART初始化和OPRATION等功能都放在r_sci_uart.c文件中,直接拿来用即可。
bsp_io_level_t pin_level = BSP_IO_LEVEL_LOW;
R_SCI_UART_Open (&g_uart9_ctrl, &g_uart9_cfg);
while (1)
{
R_BSP_PinAccessEnable();
for (uint32_t i = 0; i < leds.led_count; i++)
{
uint32_t pin = leds.p_leds[i];
R_BSP_PinWrite((bsp_io_port_pin_t) pin, pin_level);
}
R_BSP_PinAccessDisable();
R_SCI_UART_Write(&g_uart9_ctrl, "Hello, RENESAS!", 16);
if (BSP_IO_LEVEL_LOW == pin_level)
{
pin_level = BSP_IO_LEVEL_HIGH;
}
else
{
pin_level = BSP_IO_LEVEL_LOW;
}
R_BSP_SoftwareDelay(delay, bsp_delay_units);
}
直接往串口中写字符串了~
四、测试
MDK编译好了后,烧写至开发板。
嗯,效果还可以。
|