2016-11-01 10:44 AM
hello everyone
been playing with that mcu for a while but I cant set up UART IRQ DR(data register) emptyIO pins interrupts work as expected but after setting TIEN in CR2 function enableInterrupts() freezes whole chip and ISR is never hit it just hangs on that functionmy code:ISR(UART1_T_TXE_vector){ PD_ODR ^= 1<<3;}int main( void ){ UART1_CR1_.M = 1;//9 bit data inc parity bit UART1_CR3 |= 0x20;//2 stop bits UART1_BRR2 = (u8)0x02;//baud setting 9600 at 16MHz UART1_BRR1 = (u8)0x68; UART1_CR1_.PCEN = 1;//parity check enable UART1_CR1_.PS = 0;//even parity UART1_CR2_.TEN = 1;//TX enable //UART1_CR2_.TIEN = 1;//DR empty IRQ enable UART1_CR2_.REN = 1;//RX enable enableInterrupts(); u8 x = 0; u8 buf[10] = { 65,66,67,68,69,70,71,72,73,74 }; while (x<10) { UART1_DR = buf[x]; while (UART1_SR_.TXE == 0); x++; }anyone have an idea whats wrong? does it require some additional settings?2017-05-10 12:19 PM
Hello. You probably solved your issue by now, but for anyone else who comes along:
You need to add to interrupt handler routine. You need to reset the bit that signals an interrupt has occurred. Refer to the reference manual. In the UART Status register there are bits which go high for particular interrupts. Figure out which bit went high. Handle that situation. Then reset that bit.
For example, if the interrupt occurred because data is available to be read then you read the data and then reset the RXNE bit. All inside the interrupt handler.