瑞萨单片机william hill官网
直播中

大菠萝Alpha

3年用户 666经验值
擅长:嵌入式技术
私信 关注
[经验]

【瑞萨FPB-RA6E1快速原型板】USART串口demo

本次主要基于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

RA0.png

此次使用到的是USART9,即P109和P110,分别为RX和TX。
RA6.png

二、配置

打开RASC之后,Pins里面找到Peripherals,在Connectivity中找到SCI的分类,选择SCI9。

RA13.png

Operation Mode记得一定要选择成asynchronous UART,然后点箭头号进去继续配置每个Pin。

RA14.png

Pins设置好后,到Stacks中新建一个stack:

RA15.png
最后这样:

RA16.png
选择重新生成工程,MDK打开之。

三、代码

修改的不错,UART初始化和OPRATION等功能都放在r_sci_uart.c文件中,直接拿来用即可。

/* Holds level to set for pins */
    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();

        /* Update all board LEDs */
        for (uint32_t i = 0; i < leds.led_count; i++)
        {
            /* Get pin to toggle */
            uint32_t pin = leds.p_leds[i];

            /* Write to this pin */
            R_BSP_PinWrite((bsp_io_port_pin_t) pin, pin_level);
        }

        /* Protect PFS registers */
        R_BSP_PinAccessDisable();
	R_SCI_UART_Write(&g_uart9_ctrl, "Hello, RENESAS!", 16);

        /* Toggle level for next write */
        if (BSP_IO_LEVEL_LOW == pin_level)
        {
            pin_level = BSP_IO_LEVEL_HIGH;
        }
        else
        {
            pin_level = BSP_IO_LEVEL_LOW;
        }

        /* Delay */
        R_BSP_SoftwareDelay(delay, bsp_delay_units);
    }

直接往串口中写字符串了~

四、测试

MDK编译好了后,烧写至开发板。
RA17.png

嗯,效果还可以。

更多回帖

发帖
×
20
完善资料,
赚取积分