RE01-1500kb UART Communication

Dear ALL,

I downloaded the UART Communication Low Level example (https://www.renesas.com/eu/en/document/apn/re01-1500kb-256kb-group-uart-communication-low-level-code-uart-communication-sample-code-application?language=en&r=1168676) and it ran fine on the dev kit.

However, when I try to modify it to use the SCI5 (available on Arduino connector) it doesn't works at all.

I created a sci5_init() function based on the original sci4_init(), changing the speed to 115200 bps and modifying the interrupts, as follows.

static void sci5_init(void)
{

/* Lock SCI5 resource */
if (0 != R_SYS_ResourceLock(SYSTEM_LOCK_SCI5))
{

/* If the result of the resource lock is an error, do not initialize */
while (1)
{
; /* Intentionally empty braces. */
}
}

/* Start module */
R_LPM_ModuleStart(LPM_MSTP_SCI5);

/* SCR - Serial Control Register for Non-Smart Card Interface Mode.
b7 - TIE - Transmit Interrupt Enable - A TXI interrupt request is disabled.
b6 - RIE - Receive Interrupt Enable - RXI and ERI interrupt requests are disabled.
b5 - TE - Transmit Enable - Serial transmission is disabled.
b4 - RE - Receive Enable - Serial transmission is disabled.
b3 - MPIE - Multi-Processor Interrupt Enable - Normal reception.
b2 - TEIE - Transmit End Interrupt Enable - A TEI interrupt request is disabled. */
SCI5->SCR = 0x00;

/* SCR - Serial Control Register for Non-Smart Card Interface Mode.
b1:b0 - CKE[1:0] - Clock Enable - On-chip baud rate generator. The SCKn pin functions as I/O port.*/
SCI5->SCR_b.CKE = 0;

/* SMR - Serial Mode Register for Non-Smart Card Interface Mode - The set value depends on the variable.
b7 - CM - Communications Mode - Asynchronous mode or simple I2C mode.
b6 - CHR - Character Length - Transmit/receive in 8-bit data length.
b5 - PE - Parity Enable - transmitting : Parity bit addition is not performed.
receiving : Parity bit checking is not performed.
b4 - PM - Parity Mode - Selects even parity
b3 - STOP - Stop Bit Length - 1 stop bit
b2 - MP - Multi-Processor Mode - Multi-processor communications function is disabled.
b1:b0 - Clock Select - PCLK (n = 0) */
SCI5->SMR = 0x00;

/* SCMR - Smart Card Mode Register - The set value depends on the variable.
b7 - BCP2 - Base Clock Pulse 2
b6:b5 - Reserved - This bit is read as 1. The write value should be 1.
b4 - CHR1 - Character Length 1 - Transmit/receive in 8-bit data length.
b3 - SDIR - Transmitted/Received Data Transfer Direction - Transfer with LSB-first
b2 - SINV - Transmitted/Received Data Invert - TDR contents are transmitted as they are.
Received data isstored as received in the RDR register.
b1 - Reserved - This bit is read as 1. The write value should be 1.
b0 - SMIF - Smart Card Interface Mode Select - Non-smart card interface mode */
SCI5->SCMR = 0xF2;

/* SEMR - Serial Extended Mode Register
b7 - RXDESEL - Asynchronous Start Bit Edge Detection Select
- The low level on the RXDn pin is detected as the start bit.
b6 - BGDM - Baud Rate Generator Double-Speed Mode Select
- Baud rate generator outputs the clock with normal frequency.
b5 - NFEN - Digital Noise Filter Function Enable
- Noise cancellation function for the RXDn input signal is disabled.
b4 - ABCS - Asynchronous Mode Base Clock Select
- Selects 16 base clock cycles for 1-bit period.
b3 - ABCSE - Asynchronous Mode Extended Base Clock Select1
- The number of clocks in one bit period is determined
by the combination of BGDM and ABCS in the SEMR register.
b2 - BRME - Bit Rate Modulation Enable - Bit rate modulation function is disabled.
b1:b0 - Reserved - This bit is read as 0. The write value should be 0. */
//SCI4->SEMR = 0x00; //Marcellus
SCI5->SEMR = 0x5C;

/* BRR - Bit Rate Register */
//SCI4->BRR = 0x19; /* PCLK32MHz,no division, 38400bps */
SCI5->BRR = 0x2D; //115200

/* Pin setting */
R_SCI_Pinset_CH5(); /* TXD5:P3??, RXD4:P3?? */

/* SCI5_TXI - Transmit data empty */
R_SYS_IrqEventLinkSet(SYSTEM_CFG_EVENT_NUMBER_SCI5_TXI,0x1D,send_callback);
R_NVIC_SetPriority(SYSTEM_CFG_EVENT_NUMBER_SCI5_TXI,3);
R_SYS_IrqStatusClear(SYSTEM_CFG_EVENT_NUMBER_SCI5_TXI);
R_NVIC_ClearPendingIRQ(SYSTEM_CFG_EVENT_NUMBER_SCI5_TXI);

/* SCI5_TEI - Transmit end */
R_SYS_IrqEventLinkSet(SYSTEM_CFG_EVENT_NUMBER_SCI5_TEI,0x1B,send_end_callback);
R_NVIC_SetPriority(SYSTEM_CFG_EVENT_NUMBER_SCI5_TEI,3);
R_SYS_IrqStatusClear(SYSTEM_CFG_EVENT_NUMBER_SCI5_TEI);
R_NVIC_ClearPendingIRQ(SYSTEM_CFG_EVENT_NUMBER_SCI5_TEI);

/* SCI5_RXI - Receive data full */
R_SYS_IrqEventLinkSet(SYSTEM_CFG_EVENT_NUMBER_SCI5_RXI,0x1D,receive_callback);
R_NVIC_SetPriority(SYSTEM_CFG_EVENT_NUMBER_SCI5_RXI,3);
R_SYS_IrqStatusClear(SYSTEM_CFG_EVENT_NUMBER_SCI5_RXI);
R_NVIC_ClearPendingIRQ(SYSTEM_CFG_EVENT_NUMBER_SCI5_RXI);

/* SCI5_ERI - Receive error */
R_SYS_IrqEventLinkSet(SYSTEM_CFG_EVENT_NUMBER_SCI5_ERI,0x1C,receive_error_callback);
R_NVIC_SetPriority(SYSTEM_CFG_EVENT_NUMBER_SCI5_ERI,3);
R_SYS_IrqStatusClear(SYSTEM_CFG_EVENT_NUMBER_SCI5_ERI);
R_NVIC_ClearPendingIRQ(SYSTEM_CFG_EVENT_NUMBER_SCI5_ERI);

/* Enable interrupt request */
R_NVIC_EnableIRQ(SYSTEM_CFG_EVENT_NUMBER_SCI5_TXI);
R_NVIC_EnableIRQ(SYSTEM_CFG_EVENT_NUMBER_SCI5_TEI);
R_NVIC_EnableIRQ(SYSTEM_CFG_EVENT_NUMBER_SCI5_RXI);
R_NVIC_EnableIRQ(SYSTEM_CFG_EVENT_NUMBER_SCI5_ERI);

/* State setting - waiting to send */
s_sci_state = SCI_STATE_RDY;

} /* End of function sci4_init() */

And this is the send callback:

static void send_callback(void)
{
static uint8_t s_send_cnt = 0;

/* Check whether the sending data is end of string */
if (STR_PRV_END_STRING_DATA == s_send_data_buf[s_send_cnt])
{

/* If the sending data is end of string, clear send data count */
s_send_cnt = 0;

/* TIE - Transmit Interrupt Enable - A TXI interrupt request is disabled */
SCI5->SCR_b.TIE = 0;

/* TEIE - Transmit End Interrupt Request Enable - The SCIn_TXI interrupt request is enabled. */
SCI5->SCR_b.TEIE = 1;

}
else
{

/* Write transmit data of 1 byte */
SCI5->TDR_b.TDR = s_send_data_buf[s_send_cnt];

/* If There is unsent data , increase send data count */
s_send_cnt++;
}
} /* End of function send_callback() */

And the send_start() function:

static void send_start(void)
{

/* Check state */
if (SCI_STATE_RDY != s_sci_state)
{

/* If SCI4 is not ready to be sent, don't start sending */
return;
}

/* TE - Transmit Enable - Serial transmission is enabled */
/* TIE - Transmit Interrupt Enable - A TXI interrupt request is enabled */
SCI5->SCR |= 0xA0;

/* State setting - sending */
s_sci_state = SCI_STATE_BUSY;

} /* End of function send_start() */

I believe the speed calculation is right, as I could read the text on SCI4 at 115200 bps, when used that speed configuration.

Regarding the new code, it jumps to the send callback, but seems to send just one character but nothing shows up on Teraterm. Have anyone tried this before? Any tips?

Thank you very much!