Fix buggy UART baudrate calculation in the RL78 UART driver.
This commit is contained in:
parent
2e69d024a5
commit
00468a3f53
|
@ -39,13 +39,12 @@
|
||||||
#include "uart0.h"
|
#include "uart0.h"
|
||||||
|
|
||||||
#define DESIRED_BAUDRATE 9600
|
#define DESIRED_BAUDRATE 9600
|
||||||
#define FUDGE_FACTOR 4
|
|
||||||
|
|
||||||
/* Note that only 9600 and 115200 bps were tested: */
|
/* Note that only 9600, 38400, and 115200 bps were tested. */
|
||||||
#define PRESCALE_THRESH ((9600 + 115200) / 2)
|
#define PRESCALE_THRESH ((38400 + 115200) / 2)
|
||||||
#define PRS_VALUE ((DESIRED_BAUDRATE < PRESCALE_THRESH) ? 4 : 0)
|
#define PRS_VALUE ((DESIRED_BAUDRATE < PRESCALE_THRESH) ? 4 : 0)
|
||||||
#define f_MCK (f_CLK / (1 << PRS_VALUE) / FUDGE_FACTOR)
|
#define f_MCK (f_CLK / (1 << PRS_VALUE))
|
||||||
#define SDR_VALUE ((f_MCK / DESIRED_BAUDRATE) >> 1)
|
#define SDR_VALUE (f_MCK / DESIRED_BAUDRATE / 2 - 1)
|
||||||
|
|
||||||
void
|
void
|
||||||
uart0_init(void)
|
uart0_init(void)
|
||||||
|
|
Loading…
Reference in a new issue