main: enable UART

This commit is contained in:
King Kévin 2021-08-17 08:49:48 +02:00
parent a66a60fbad
commit 3e9a10ac08
1 changed files with 8 additions and 1 deletions

9
main.c
View File

@ -170,7 +170,7 @@ void main(void)
while (!CLK->ICKR.fields.HSIRDY); // wait for internal oscillator to be ready
// save power by disabling unused peripheral
CLK_PCKENR1 = CLK_PCKENR1_I2C; // keep I²C
CLK_PCKENR1 = CLK_PCKENR1_I2C | CLK_PCKENR1_UART1234; // keep I²C and UART
CLK_PCKENR2 = CLK_PCKENR2_AWU; // keep AWU
// configure LEDs
@ -194,6 +194,13 @@ void main(void)
AWU->APR.fields.APR = 0x3e; // set time to 256 ms
AWU_CSR |= AWU_CSR_AWUEN; // enable AWU (start only when entering wait or active halt mode)
// configure UART for debug output
UART1->CR1.fields.M = 0; // 8 data bits
UART1->CR3.fields.STOP = 0; // 1 stop bit
UART1->BRR2.reg = 0x0B; // set baud rate to 115200 (at 16 MHz)
UART1->BRR1.reg = 0x08; // set baud rate to 115200 (at 16 MHz)
UART1->CR2.fields.TEN = 1; // enable TX
// load function in RAM
ram_cpy();