Skip to content

Commit

Permalink
drivers: serial: ra: reduce uart baud rate error
Browse files Browse the repository at this point in the history
Using the 8 base clock cycles per bit period setting (instead of 16)
reduces the uart baud rate error when using a 12MHz crystal (found on
many RA Microcontroller development kits boards). This setting also
slightly reduces the error when using the internal 48MHz oscillator,
used by the Arduino UNO R4 Minima board currently support by Zephyr.

Signed-off-by: Ian Morris <[email protected]>
  • Loading branch information
iandmorris authored and dleach02 committed Feb 5, 2024
1 parent caacc27 commit 826d67a
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions drivers/serial/uart_renesas_ra.c
Original file line number Diff line number Diff line change
Expand Up @@ -216,11 +216,11 @@ static void uart_ra_set_baudrate(const struct device *dev, uint32_t baud_rate)
uint8_t reg_val;

reg_val = uart_ra_read_8(dev, SEMR);
reg_val |= REG_MASK(SEMR_BGDM);
reg_val &= ~(REG_MASK(SEMR_BRME) | REG_MASK(SEMR_ABCSE) | REG_MASK(SEMR_ABCS));
reg_val |= (REG_MASK(SEMR_BGDM) | REG_MASK(SEMR_ABCS));
reg_val &= ~(REG_MASK(SEMR_BRME) | REG_MASK(SEMR_ABCSE));
uart_ra_write_8(dev, SEMR, reg_val);

reg_val = (data->clk_rate / (16 * data->current_config.baudrate)) - 1;
reg_val = (data->clk_rate / (8 * data->current_config.baudrate)) - 1;
uart_ra_write_8(dev, BRR, reg_val);
}

Expand Down

0 comments on commit 826d67a

Please sign in to comment.