Hello!
I am on the KEAZ128 micro and I am trying to get UART working with interrupts. What is I am finding is that my program is constantly getting stuck in the ISR, as if an interrupt is constantly being trigger, yet without enabling any interrupt flags on the UART line that I'm using. To enable interrupts I am using the following:
NVIC_ICPR |= 1 <<14; /* 14 is the IRQ number of UART2 interrupt*/
NVIC_ISER |= 1 <<14; /* 14 is the IRQ number of UART2 interrupt*/
which is just enabling clear pending interrupts and then enabling interrupts.
Has anyone seen this before?
Initialization code that worked:
SIM_SCGC |= SIM_SCGC_UART0_MASK; /* Enable bus clock in UART2*/
UART0_BDH = 0; /* One stop bit*/
UART_SetBaudrate(24000000, 115200);
UART0_C1 = 0; /* No parity enable,8-bit format*/
UART0_C2 |= UART_C2_TE_MASK; /* Enable Transmitter*/
UART0_C2 |= UART_C2_RE_MASK; /* Enable Receiver*/
UART0_C2 |= UART_C2_RIE_MASK; /* Enable Receiver interrupts*/
and the code that doesn't work is from the FRDM_KEA128 example drivers
Hi Alexandra Dickie,
What the code you are using? The code in FRDM-KEA-QSP?
FRDM-KEA-QSP\Quick Start Package v5\SDK Drivers and Code Example Projects\FRDM-KEAZ128\Driver Test SW for KEAZ128\Driver Test SW for KEAZ128\FRDM_KEA128_UART_Interrupt?
If yes, this code is enable the UART send interrupt. if the Tx buffer is empty, the code will enter interrupt, it is correct.
Your code just enable the RX interrupt, so when you send the data, you still using the polling, the code won't enter the interrupt.
Actually, the function is freely designed by the customer.
Wish it helps you!
If you still have question, please contact me!
Have a great day,
Kerry
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
I fixed my problem by not using the example code for this micro that was actually from the kinetis website! The uart initialization function was all buggy. @Kinetis maybe not publish code with that many bugs :smileysad:
Hi
If the interrupts haven't been enable in UART2_C2 it should not be possible for them to reach the NVIC; I haven't experienced anything like that.
See these for references:
http://www.utasker.com/kinetis/TRK-KEA128.html
http://www.utasker.com/kinetis/FRDM-KEAZ128Q80.html
with interrupt driven UART on the OpenSDA VCOM interfaces.
Regards
Mark