USART0 interrupt not working on a AT81SAM7S256

OP #1173523
I have an Atmel AT91SAM7S-EK and am experiencing some difficulty. I am
having trouble with the USART0 interrupt. I can’t get it to work. I
never get USART0 interrupts and I am ready to pull my hair out. CAN
ANYBODY HELP?

This code looks different because I edited the AT91SAM7S256.H file so
that the uC registers are no longer inside structures. I also got rid of
all the “AT91C_” prefixes. I design embedded systems for a living and
have been doing it for 19 years. All those keystrokes are unproductive
and unnecessary.

I enable my timer interrupt as below and it works:

  // enable the Timer0 peripheral clock
  PMC_PCER = (1 << ID_TC0);       // enable Timer0 peripheral clock

  // Set up the AIC  registers for Timer 0
  AIC_IDCR = (1 << ID_TC0);        // Disable timer 0 interrupt in AIC
Interrupt Disable Command Register

  // Set the TC0 IRQ handler address in AIC Source
  AIC_SVR[ID_TC0] = Timer0_ISR;    // Vector Register[12]

  // Set the interrupt source type and priority
  AIC_SMR[ID_TC0] = 0x00000007;    // in AIC Source Mode Register[12]

  AIC_ICCR = (1 << ID_TC0);  // Clear the TC0 interrupt in AIC Interrupt
  AIC_IDCR = (0 << ID_TC0);  // Remove disable timer 0 interrupt
  AIC_IECR = (1 << ID_TC0);  // Enable the TC0 interrupt

I enabled my PIOA interrupt as below and it works:

  // enable the PIOA peripheral clock
  PMC_PCER = (1 << ID_PIOA);

  // Set up the AIC  registers for Timer 0
  AIC_IDCR = (1 << ID_PIOA);       // Disable timer 0 interrupt

  // Set the TC0 IRQ handler address in AIC Source
  AIC_SVR[ID_PIOA] = PioaISR;    // Vector Register[12]

  // Set the interrupt source type and priority
  AIC_SMR[ID_PIOA] = 0x00000002;    // in AIC Source Mode Register[12]

  AIC_ICCR = (1 << ID_PIOA);  // Clear the TC0 interrupt
  AIC_IDCR = (0 << ID_PIOA);  // Remove disable timer 0 interrupt
  AIC_IECR = (1 << ID_PIOA);  // Enable the TC0 interrupt


I enable my USART0 interrupt as below and it does not work:

  // enable interrupts on TXRDY, RXRDY
  US0_IDR = ~0x03;     // disable all but what is used
  US0_IER = 0x03;

  // Set up the AIC  registers for USART 0
  AIC_IDCR = (1 << ID_US0);        // Disable usart 0 interrupt

  // Set the USART0 IRQ handler address in AIC Source
  AIC_SVR[ID_US0] = (uint32) Usart0_ISR;    // Vector Register[6]

  // Set the interrupt source type and priority
  AIC_SMR[ID_US0] = 0x00000001;    // in AIC Source Mode Register[6]

  AIC_ICCR = (1 << ID_US0);  // Clear the US0 interrupt
  AIC_IDCR = (0 << ID_US0);  // Remove disable usart 0 interrupt
  AIC_IECR = (1 << ID_US0);  // Enable the US0 interrupt
  PMC_PCER = (1 << ID_US0);       // enable the USART0 peripheral clock

Reply

A question of your own? This thread is over 18 years old. Ask it in a thread of its own – more people read along there, and it gets answered more often and sooner.

Start a new thread

A fix, an addition or feedback on this thread? Then reply here.

Formatting
  • [c]C-Code[/c]
  • [code]code in other languages, ASCII drawings[/code]
  • [math]formula (LaTeX syntax)[/math]
  • [[Title]] – link to an article
  • Link to another post: right-click its post ID (#8078628), copy the address, paste it into the text

More about formatting

Post long source code as an attachment, not in the text.

Already registered? Log in

Not shown to anyone. We send you a link; your post appears once you confirm it there.

By submitting you create a free account and accept the terms of use.