EmbeddedRelated.com
Forums

urgent: AT91SAM7SE512: UART Reciver Interrupt is not working

Started by nanjooh October 12, 2007
Hi,

I am working in
Controller : AT91SAM7SE512
Tool : KEIL uVision 3V3.53

I have a problem in UART Receiver interrupt.
I have downloaded a sample source code from
http://www.atmel.com/dyn/products/product_card.asp?part_id940
website.
i am using UART0 for transmission and reception,No problem in the
transmission.
For RX i am using the interrupt.If i type the any data in the Hyper
terminal there is no response.If anybody having the sample source code
please give me.

This is my source code for your reference,

// Include Standard LIB files
#include "Board_inout_define.h"

extern void delay ( int ); /*Delay function*/

#define AT91_BAUD_RATE 9600
#define USART_INTERRUPT_LEVEL 5
//* Standard Asynchronous Mode : 8 bits , 1 stop , no parity
#define AT91C_US_ASYNC_MODE ( AT91C_US_USMODE_NORMAL + \
AT91C_US_NBSTOP_1_BIT + \
AT91C_US_PAR_NONE + \
AT91C_US_CHRL_8_BITS + \
AT91C_US_CLKS_CLOCK )
void usart0_isr (void)
{
volatile unsigned int status_reg;
//delay(1);
status_reg = AT91C_BASE_US0->US_CSR;

if ( status_reg & AT91C_US_RXRDY)
{
//* Get byte and send
AT91F_US_PutChar (AT91C_BASE_US0, AT91F_US_GetChar(AT91C_BASE_US0));

}

if ( status_reg & AT91C_US_OVRE) {
//* clear US_RXRDY
AT91F_US_GetChar(AT91C_BASE_US0);
AT91F_US_PutChar (AT91C_BASE_US0, 'O');
}

//* Check error
if ( status_reg & AT91C_US_PARE) {
AT91F_US_PutChar (AT91C_BASE_US0, 'P');
}

if ( status_reg & AT91C_US_FRAME) {
AT91F_US_PutChar (AT91C_BASE_US0, 'F');
}

if ( status_reg & AT91C_US_TIMEOUT){
AT91C_BASE_US0->US_CR = AT91C_US_STTTO;
AT91F_US_PutChar (AT91C_BASE_US0, 'T');
}

//* Reset the satus bit
AT91C_BASE_US0->US_CR = AT91C_US_RSTSTA;

AT91C_BASE_AIC->AIC_EOICR = AT91C_BASE_US0->US_CSR; //
Interrupt Ack
AT91C_BASE_AIC->AIC_ICCR = (1 << AT91C_ID_US0); // Interrupt Ack
*AT91C_AIC_EOICR = 0; // End of
Interrupt

}
void serial_Usart0_init(void)
{
AT91PS_USART COM0 = AT91C_BASE_US0;

//* First, enable the clock of the USART
AT91C_BASE_PMC->PMC_PCER = (1 << AT91C_ID_US0);

//* Configure PIO controllers to periph mode
AT91C_BASE_PIOA->PIO_ASR = (((unsigned int) AT91C_PA5_RXD0 )
|((unsigned int) AT91C_PA6_TXD0));
AT91C_BASE_PIOA->PIO_BSR = 0;
AT91C_BASE_PIOA->PIO_PDR = ((((unsigned int) AT91C_PA5_RXD0 )
|((unsigned int) AT91C_PA6_TXD0)) | 0); // Set in Periph mode

//* Usart Configure
AT91F_US_Configure (AT91C_BASE_US0, AT91B_MCK, AT91C_US_ASYNC_MODE,
AT91_BAUD_RATE, 0);

//* Enable usart
COM0->US_CR = AT91C_US_RXEN | AT91C_US_TXEN;

//* Enable USART IT error and RXRDY
AT91F_US_EnableIt(COM0, AT91C_US_TIMEOUT |
AT91C_US_FRAME |
AT91C_US_OVRE |
AT91C_US_RXRDY);

// open Usart 1 interrupt
AT91F_AIC_ConfigureIt ( AT91C_BASE_AIC, AT91C_ID_US0,
USART_INTERRUPT_LEVEL,AT91C_AIC_SRCTYPE_HIGH_LEVEL,usart0_isr );

AT91F_AIC_EnableIt (AT91C_BASE_AIC, AT91C_ID_US0);

}

PLEASE ADVICE ME ON THIS.

With regards and thanks,
Murthy.R
Hi friends,

I have posted this problem in KEIL forum and AT91 Forum.

Nobody is giving a solution for this problem.

If anybody have sample code means please give it to me.

Controller=AT91SAM7SE512
TOOL= KEIL uVision 3.53
Please help me to solve this problem.
With regards,
Murthy.R

nanj moorthy wrote: Hi Jon,

Thanks for your reply.
I have given this ACK in the ISR.But still it is not working.
This is my UART0 Initialization code,is there i have to do any changes,
because when i Enable the IT the code is not working.

for your reference,
void uart0Init(void)
{
// enable the clock of UART0
AT91C_BASE_PMC->PMC_PCER = (1< // enable uart pins on PIO
*AT91C_PIOA_PDR = AT91C_PA5_RXD0 | AT91C_PA6_TXD0;
// select peripheral connection
*AT91C_PIOA_ASR = AT91C_PA5_RXD0 | AT91C_PA6_TXD0;
// disable I/O pullup
*AT91C_PIOA_PPUDR = AT91C_PA5_RXD0;
// reset the UART
AT91C_BASE_US0->US_CR = AT91C_US_RSTRX | AT91C_US_RSTTX | AT91C_US_RXDIS |AT91C_US_TXDIS;
// set serial line mode
AT91C_BASE_US0->US_MR = AT91C_US_ASYNC_MODE;
// set the baud rate
AT91C_BASE_US0->US_BRGR = BAUD_VALUE(9600);
// enable the uart
AT91C_BASE_US0->US_CR = AT91C_US_RXEN | AT91C_US_TXEN;

// enable reaction on different interrupt sources
AT91C_BASE_US0->US_IDR = 0xFFFFFFFF;
AT91C_BASE_US0->US_IER = AT91C_US_RXRDY;

// configure USART0 interrupt
AT91C_BASE_AIC->AIC_IDCR = 0x1 << AT91C_ID_US0;
AT91C_BASE_AIC->AIC_SVR[AT91C_ID_US0] = (unsigned long) Usart0Int;
AT91C_BASE_AIC->AIC_SMR[AT91C_ID_US0] = AT91C_AIC_SRCTYPE_HIGH_LEVEL |2;

AT91C_BASE_AIC->AIC_IECR = 0x1 << AT91C_ID_US0;

}

Is this code Right?

Please check this and advise me on this.

Please.................
With regards,
Murthy.R

willoughby_jon wrote:
If you set a break point in the ISR does it ever get there?
If not, check IRQ vector (0x18) has the following code:
ldr pc,[pc,#-0xF20]

The AIC manages the prioritization by using an internal stack on which
the current interrupt level is automatically pushed when AIC_IVR is
read, and popped when AIC_EOICR is written (any value), so

AT91C_BASE_AIC->AIC_EOICR = AT91C_BASE_US0->US_CSR;
and
*AT91C_AIC_EOICR = 0;

acknowledges twice at the end of your ISR. I think using
AT91C_BASE_AIC->AIC_EOICR = 0;
would be fine...
Jon

---------------------------------
Be a better Globetrotter. Get better travel answers from someone who knows.
Yahoo! Answers - Check it out.

---------------------------------
Boardwalk for $500? In 2007? Ha!
Play Monopoly Here and Now (it's updated for today's economy) at Yahoo! Games.