I am new to STM8, and trying to use a STM8S103F3, using IAR Embedded Workbench. Using C, I like to use the registers directly. I need serial on 14400 baud, 8N2, and getting the UART transmit is easy, as there are numerous good tutorials and examples on the net. Then the need is to have the UART receive on interrupt, nothing else will do. That is the problem. According to iostm8s103f3.h (IAR) there are 5 interrupts on 0x14 vector UART1_R_IDLE, UART1_R_LBDF, UART1_R_OR, UART1_R_PE, UART1_R_RXNE
According to Silverlight Developer: Registers on the STM8,
Vector 19 (0x13) = UART_RX
According to ST Microelectronics STM8S.h
#define UART1_BaseAddress 0x5230
#define UART1_SR_RXNE ((u8)0x20) /*!< Read Data Register Not Empty mask */
#if defined(STM8S208) ||defined(STM8S207) ||defined(STM8S103) ||defined(STM8S903)
#define UART1 ((UART1_TypeDef *) UART1_BaseAddress)
#endif /* (STM8S208) ||(STM8S207) || (STM8S103) || (STM8S903) */
According to STM8S Reference manual RM0016 The RXNE flag (Rx buffer not empty) is set on the last sampling clock edge, when the data is transferred from the shift register to the Rx buffer. It indicates that a data is ready to be read from the SPI_DR register. Rx buffer not empty (RXNE) When set, this flag indicates that there is a valid received data in the Rx buffer. This flag is reset when SPI_DR is read. Then I wrote:
#pragma vector = UART1_R_RXNE_vector //as iostm8s103f3 is used, that means 0x14
__interrupt void UART1_IRQHandler(void)
{ unsigned character recd;
recd = UART1_SR;
if(1 == UART1_SR_RXNE) recd = UART1_DR;
etc. No good, I continually get interrupts, UART1_SR_RXNE is set, but UART1_DR is empty, and no UART receive has happened. I have disabled all other interrupts I can see that can vector to this, and still no good. The SPI also sets this flag, presumably the the UART and SPI cannot be used together. I sorely need to get this serial receive interrupt going. Please help. Thank you