Question
STM8S001J3 UART remap
Posted on January 05, 2018 at 10:14
Hi
STM8S001J3 There is a problem with UART communication.
If PIN8 is used without remapping tx, it works well.
If tx is remapped and used as PIN5, the following code will not work.
void UART1_init(void)
{CLK->CKDIVR = 0x00;
CLK->PCKENR1 |= 0x20;
// enable clock for USART
UART1->BRR2 = 0x0B;
// BaudRate 115200
UART1->BRR1 = 0x08; UART1->CR2 = 0x2C;
// RIEN = ENABLE, TEN = ENABLE, REN = ENABLE}
void main(void)
{
UART1_init();
enableInterrupts();while(1);
}
INTERRUPT_HANDLER(UART1_RX_IRQHandler, 18)
{ if(UART1->SR & 0x20) { char temp = UART1->DR; while(!(UART1->SR & 0x80)); UART1->DR = temp; }}#stm8s