cancel
Showing results for 
Search instead for 
Did you mean: 

STM8S UART interrupt enable and disable

Kmax18
Senior

I am testing the STM8S Standard Peripheral Library (SPL) using the STVD IDE, Cosmic compiler, and a Nucleo-8S208RB development board.

The SPL example 'UART1_interrupt' initializes the UART1 TX and UART3 RX interrupts using the below UART_Config() function at the start of main(). It appears this is the only time the interrupts are enabled, and I am wondering how this can work during continuous, back & forth between UART1 and UART3. (I added a while loop to the example for continuous communication.)

After a UART1->UART3 transmission the interrupt routines disable the interrupts UART1_IT_TXE and UART3_IT_RXNE_OR, which is the usual method. However, it appears the interrupts are never enabled again, and yet continuous UART communication works.

However, for UART3->UART1 transmissions in the opposite direction the SPL example does exactly that: interrupts UART1_IT_RXNE_OR and UART3_IT_TXE are enabled for each new transmission. Why the discrepancy betweem UART1 -> UART3, and UART3 -> UART1?

Thanks for the support!

static void UART_Config(void)

{

  ...

  UART1_ITConfig(UART1_IT_TXE, ENABLE);

  ...

  UART3_ITConfig(UART3_IT_RXNE_OR, ENABLE);

  enableInterrupts();

}

0 REPLIES 0