Contenido principal

Baud Rate Configuration for SCI3 and RLIN3 Communication Modules

R2026b

This topic describes how baud rate is configured for the SCI3 and RLIN3 communication modules used by the Complex Device Driver (CDD) on Renesas RH850 microcontrollers. Baud rate configuration affects UART communication used for external mode and other serial communication workflows.

The current CDD for U2A and U2B devices supports configuration of:

  • SCI130

  • RLIN3

Use this topic to understand:

  • which peripheral is available on your target device

  • how baud rate is calculated for SCI3 and RLIN3

  • where the baud rate settings are defined in the generated CDD code

Use this information to understand which peripheral is available on your target device and how the configured register values determine the communication baud rate.

Serial Communication Peripheral Availability

RLIN3 is the peripheral used for UART communication on U2B devices and U2A6 device series.

SCI3 is available only on U2A16 and U2A8 device series.

PeripheralU2A16U2A8U2A6U2B6U2B10
SCI330000
RLIN324 (max), 12 (min)24 (max), 12 (min)12 (max), 8 (min)77

On the U2A starter kit, the SCI30 module connects to the on-board USB/UART debugger. Therefore, the initial support uses SCI30 as the peripheral for serial communication. However, the U2A motor control kit uses the RLIN33 module.

The current CDD for U2A and U2B supports configuration of the SCI30 module and the RLIN33 module.

Baud Rate Calculation in SCI3

In the SCI3 module, baud rate is determined by the values configured in the SCI3nBRR and SCI3nMDDR registers.

The baud rate depends on:

  • the peripheral clock

  • the clock selection value, α

  • the SCI3nBRR value

  • the SCI3nMDDR value

  • the ABCS and BGDM settings in SCI3nSEMR

The clock source for the SCI3 module is CLK_HSB.

SCI3 Baud Rate Formula

The baud rate formula depends on the communication mode and the ABCS and BGDM settings.

For asynchronous mode:

  • ABCS = 0, BGDM = 0

    B = PCLK × 10^6 / (64 × 2^(2α - 1) × (256/MDDR) × (N + 1))
  • ABCS = 0, BGDM = 1 or ABCS = 1, BGDM = 0

    B = PCLK × 10^6 / (32 × 2^(2α - 1) × (256/MDDR) × (N + 1))
  • ABCS = 1, BGDM = 1

    B = PCLK × 106 / (16 × 2(2α − 1) × (256/MDDR) × (N + 1))

For clock synchronous mode:

B = PCLK × 10^6 / (16 × 2^(2α - 1) × (256/MDDR) × (N + 1))

Where:

  • B is the bit rate in bps

  • PCLK is the operating frequency in MHz

  • N is the baud rate generator setting value in SCI3nBRR (0 ≤ N ≤ 255)

  • MDDR is the modulation duty value in SCI3nMDDR (128 ≤ MDDR ≤ 255)

  • α is the clock selection value determined by SCI3nSMR

SCI3 Clock Selection Value

The value of α is determined by the CKS1 and CKS0 bits in the SCI3nSMR register.

CKS1CKS0α
000
011
102
113

The clock source for the SCI3 module is CLK_HSB.

Note

N is the bit rate register setting value of baud rate generator (N ≥ 1). Refer to the hardware user manual Table 25.17 for the relationship between Setting N in SCI3nBRM and Bit Rate B.

SCI3 Baud Rate Initialization Sequence

The baud rate setting must follow this initialization sequence. After reset, TE = RE = MDDRS = 0.

  1. Clear the TE and RE bits in SCI3nSCR. Also clear the TIE, TEIE, MPIE, and RIE bits to 0. When clock output is selected in asynchronous mode, the clock is output immediately after SCI3nSCR settings are made.

  2. Set the CKE1 and CKE0 bits in SCI3nSCR (TE and RE bits must remain 0).

  3. Set the transfer format in:

    • SCI3nSMR

    • SCI3nSCMR

  4. Clear the MDDRS bit in SCI3nSEMR, and set the ABCS bit based on the bit rate configuration for SCI3nBRR.

  5. Set a value in SCI3nBRR.

  6. Set the BRME and MDDRS bits in SCI3nSEMR to 1, and set a bit rate error correction value in SCI3nMDCR.

  7. Set a value in SCI3nMDDR.

  8. Set the TE or RE bit in SCI3nSCR to 1 to enable transmission or reception.

    To enable both transmission and reception, set TE and RE simultaneously using one instruction.

Baud Rate for SCI30 Module in CDD

For the SCI30 module, the initialization routine is present in:

Config_SCI30.c

The two register settings that determine the baud rate are:

  • SCI30.BRR.UINT8

  • SCI30.MDDR.UINT8

These register values are set from macro definitions in:

Config_SCI30.h

The generated code uses these definitions:

#define _SCI30_MODULATION_DUTY    (0xB1U)
#define _SCI30_BIT_RATE           (0x0EU)

These values currently result in a baud rate of 460800 bps.

If you want to use a different baud rate, update these register values in your application code or override the generated initialization. Moving the baud rate configuration to application-level initialization makes the baud rate editable without manually changing generated code each time.

Baud Rate Calculation in RLIN3

In the RLIN3 module, baud rate depends on two registers:

  • RLN3nLWBR

  • RLN3nLBRP01

The peripheral clock for RLIN3 comes from CLK_RLIN3, which is configured in the MCU module in the CDF file.

Use this formula to calculate the baud rate:

Baud Rate = CLK_RLIN3 / clock_prescaler / no_of_samples / (L + 1)

Where:

  • clock_prescaler is determined by RLN3nLWBR.LPRS

  • L is the value in RLN3nLBRP01 (UART Baud Rate Prescaler 01)

  • no_of_samples is determined by RLN3nLWBR.NSPB

RLN3nLWBR Register Settings

The RLN3nLWBR register controls the sampling count and prescaler clock selection.

NSPB[3:0] — Bit Sampling Count Select

SettingSampling Count
000016
00114
01016
01107
01118
10009
100110
101011
101112
110013
110114
111015
110016

LPRS[2:0] — Prescaler Clock Select

SettingPrescaler
0001/1
0011/2
0101/4
0111/8
1001/16
1011/32
1101/64
1111/128

Baud Rate for RLIN33 Module in CDD

For the RLIN33 module, the default CLK_RLIN3 clock configured in the CDF file is 10 MHz.

The baud rate is configured in the generated initialization routine for UART3, where these settings determine the final baud rate:

  • RLIN33.LWBR.UINT8

  • RLIN33.LBRP01.UINT16

The generated code uses the baud rate prescaler macro:

#define _UART3_BAUD_RATE_PRESCALER    (0x0000U)

and configures the UART settings in the initialization routine.

Based on the generated settings shown in the CDD:

  • CLK_RLIN3 = 10 MHz

  • sampling count = 7

  • prescaler = 1

  • L = 0

So the baud rate is:

Baud Rate = 10,000,000 / 1 / 7 / (0 + 1)
          = 1,428,571 bps

Therefore, the current generated configuration for RLIN33 results in a baud rate of approximately 1.43 Mbps.

If you want to use a different baud rate, update the RLIN3 prescaler and sampling configuration in the initialization code or override the generated settings at the application level.

See Also