Thanks, that's made it a bit more clear.
I thought i wasn't clearing the interrupt, but couldn't figure why.
Cheers :)
Reply by microbit_virgin●November 21, 20072007-11-21
A few things wrong there, this can be confusing at the start :
> AT91C_BASE_AIC->AIC_EOICR = 0; then execution hangs.
You only do this when you have SW handler, and call your ISR from there.
Note that this should be the LAST thing you do AFTER returning from your
ISR.
With HW handler this is taken care of.
> Is it because the PDC HAS to be used with UART recieve interrupt?
No, this is optional and not necessary in your case.
> When I enable a Uart recieve interrupt, it either continually
> interrupts, or if I clear the interrupt in the AIC with:
This is because you're not handling the interrupt properly. Read the
users' guide on
USART and AIC.
Basically first of all you need to distinguish between TX and RX interrupt.
Secondly, if you indeed have an RX interrupt, you need to clear the interrupt
by reading RHR
(which is why you get continuous interrupts)
An example (using SW AIC handler, excerpt from CrossWorks ARM code, adjust for
IAR lib)
void uart0_isr (void)
{
UINT status = US0_CSR;
if (status & US_TXRDY) // Data to TX ?
{
// yes, check if more data to send
if (rs232_tx_head != rs232_tx_tail)
{
US0_THR = rs232_tx[rs232_tx_tail++];
rs232_tx_tail %= RS232_SIZE;
rs232_tx_chars--; // update # of TX
chars
}
else
{
CLRB(ext_flags,COMM_TX_RUNNING); // Done flushing TX buffer
US0_IDR = US_TXRDY; // clear transmit interrupt
}
}
// check for receive errors
if (status & (US_RXBRK | US_OVRE | US_FRAME | US_PARE))
US0_CR = US_RSTSTA; // clear them
// check for RX character ready
if (status & US_RXRDY)
{
char ch = US0_RHR; // buffer the RXd char
// DO YOUR THING HERE for RX INTs
}
}
Best Regards,
Kris
-----Original Message-----
From: A... [mailto:A...] On Behalf Of userpaul2
Sent: Wednesday, 21 November 2007 9:42 PM
To: A...
Subject: [AT91SAM] USART0 Recieve Interrupt does not return.
When I enable a Uart recieve interrupt, it either continually
interrupts, or if I clear the interrupt in the AIC with:
AT91C_BASE_AIC->AIC_EOICR = 0; then execution hangs.
Both situations prevent the running of both the program and
higher priority interrupts.
Does anybody know why this is?
Is it because the PDC HAS to be used with UART recieve interrupt?
When I enable a Uart recieve interrupt, it either continually
interrupts, or if I clear the interrupt in the AIC with:
AT91C_BASE_AIC->AIC_EOICR = 0; then execution hangs.
Both situations prevent the running of both the program and
higher priority interrupts.
Does anybody know why this is?
Is it because the PDC HAS to be used with UART recieve interrupt?