Receive 4 bytes data by UART and transmit the received data as they are. Stop UART after transmission is finished.
[GUI setting example]
Serial |
Used | |||
SAU0 |
Used | |||
Channel0 |
||||
Channel 0 |
UART0 (Transmission/Receive) | |||
Data length setting (Receive) |
8 bits | |||
Trasfer direction setting (Receive) |
LSB | |||
Parity setting (Receive) |
None | |||
Stop bit length setting (Receive) |
1 bit fixed | |||
Receive data level setting |
Normal | |||
Transfer rate setting (Receive) |
9600(bps) (error:+0.16% Minimum permissible value:-5.17% Maximum permissible value:+5.16%) | |||
Reception end interrupt priority (INTSR0) |
Low | |||
Reception end (Callback function setting) |
Used | |||
Reception error (Callback function setting) |
Used | |||
Transfer mode setting |
Single transfer mode | |||
Data length setting (Transmit) |
8 bits | |||
Transfer direction setting (Transmit) |
LSB | |||
Parity setting (Transmit) |
None | |||
Stop bit length setting (Transmit) |
1 bit | |||
Transmit data level setting |
Normal | |||
Transfer rate setting (Transmit) |
9600(bps) (error: +0.16%) | |||
Transmit end interrupt priority (INTST0) |
Low | |||
Transmission end (Callback function setting) |
Used |
[API setting example]
r_main.c
/* Start user code for global. Do not edit comment generated here */
extern volatile uint8_t g_uart0_buf[4];
/* End user code. Do not edit comment generated here */
void main(void)
{
R_MAIN_UserInit();
/* Start user code. Do not edit comment generated here */
/* Start the UART0 module operation */
R_UART0_Start();
/* Receive UART0 data */
R_UART0_Receive((uint8_t *)g_uart0_buf, 4U);
while (1U)
{
;
}
/* End user code. Do not edit comment generated here */
}
r_cg_serial_user.c
/* Start user code for global. Do not edit comment generated here */
volatile uint8_t g_uart0_buf[4];
/* End user code. Do not edit comment generated here */
static void r_uart0_callback_receiveend(void)
{
/* Start user code. Do not edit comment generated here */
/* Send UART0 data */
R_UART0_Send((uint8_t *)g_uart0_buf, 4U);
/* End user code. Do not edit comment generated here */
}
static void r_uart0_callback_sendend(void)
{
/* Start user code. Do not edit comment generated here */
/* Stop the UART0 module operation */
R_UART0_Stop();
/* End user code. Do not edit comment generated here */
}