EmbDev.net

Forum: ARM programming with GCC/GNU tools USART0 interrupt not working on a AT81SAM7S256


von Harold R. (hlritter)


Rate this post
useful
not useful
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

Please log in before posting. Registration is free and takes only a minute.
Existing account
Do you have a Google/GoogleMail account? No registration required!
Log in with Google account
No account? Register here.