AT91SAM7x256 & USART0 interrupt

Comments

7 comments

  • Avatar
    John Franklin

    Hi Christoph.

    I'm wondering why the line that enables  USART0 in DMA transfer mode. The rest of the code looks like you you plan to use non DMA mode, were each received byte invokes the receive ISR. If this is the case then I think the line:

     US0_PTCR = US0_PTCR_TXTEN | US0_PTCR_RXTEN;   // Enable the RX and TX PDC transfer requests

    should be removed. 

    If I'm worng, applogies for wasting your time.

    Regards,

    John

    0
    Comment actions Permalink
  • Avatar
    Christoph Klein

    Thanks for Your answer, John!

    Mr. Lynch (with whose tutorial I have been trying all this) has provided one interrupt- and one DMA-centered variant.

    I must have slipped there.

    But still: it doesn't work.

    In debugging mode US_CSR shows me lots of 'ticks' like 'RXRDY', 'TXRDY', 'ENDRX', 'ENDTX' and so on.

    Should that somehow be cleared beforehand? US_IMR shows a tick at RXRDY. Anything else I could look up in the registers?

     

    Regards,

    Christoph

     

    0
    Comment actions Permalink
  • Avatar
    John Franklin

    Hi Christoph.

    I need to refresh my memory. I'll look tomorrow and get back to you.

    I have functioing code for USART0/1 for this processor and board, which you are welcome to. I'm afraid its C++, but hopefully it may still be of some use.

    Regards,

    John

    0
    Comment actions Permalink
  • Avatar
    Christoph Klein

    I'd really appreciate that. Thanks, John!

    Apart from that: anything I could try until then? Anyone?

    Christoph

     

    0
    Comment actions Permalink
  • Avatar
    John Franklin
    Hi Christoph.
    Apologies for the late reply. I had to re-build a test project using US0 to check on the settings of the various interrupt related flags.
    I don't see any obvious errors in your code. You seem to have all the major initialisation steps in place.
    In debug looking at the following registers:
    AIC register. The entry for AIC_SVR6 should be set to non 0.  This is the vector to your ISR handler which is set by the call to ctl_set_isr(...
    AIC_IMR should have a tick for US0
    AIC_IPR; if the entry for US0 is 1 then the AIC has detected an interrupt from US0 but has not yet processed it. If your code is working as intended this flag will generally be seen at 0.
    A likely cause for it being stuck at 1 is that global interrupts are disabled. See below.
    AIC_IMR; the entry for US0 should be a 1.
    US0_IMR should have the RXRDY flag set.
    The CPU Current mode register cpsr should have the I flag at 0. This is the global interrupt flag. If it is 1 then all interrupts (expect fast interrupts) are disabled. 
    If you see this at 1 then its likely that something is missing in your initialisation code that should have globally enable interrupts.
    If you let me have an email address I will send you my relevant source files.
    Regards,
    John

    Hi Christoph.
    Apologies for the late reply. I had to re-build a test project using US0 to check on the settings of the various interrupt related flags.

    I don't see any obvious errors in your code. You seem to have all the major initialisation steps in place.


    In debug looking at the following registers:
    AIC register. The entry for AIC_SVR6 should be set to non 0.  This is the vector to your ISR handler which is set by the call to ctl_set_isr(...


    AIC_IMR should have a tick for US0


    AIC_IPR; if the entry for US0 is 1 then the AIC has detected an interrupt from US0 but has not yet processed it. If your code is working as intended this flag will generally be seen at 0.A likely cause for it being stuck at 1 is that global interrupts are disabled. See below.


    AIC_IMR; the entry for US0 should be a 1.


    US0_IMR should have the RXRDY flag set.


    The CPU Current mode register cpsr should have the I flag at 0. This is the global interrupt flag. If it is 1 then all interrupts (expect fast interrupts) are disabled. If you see this at 1 then its likely that something is missing in your initialisation code that should have globally enable interrupts.


    If you let me have an email address I will send you my relevant source files.
    Regards,John

    0
    Comment actions Permalink
  • Avatar
    Christoph Klein

    Now, I sincerely wish I could say something like "this will never happen to me again: to forget enabling interrupts" but I remember vaguely haven't had a rather similar problem with the AVRs before :)

    Anyway, I've seen my first US0_RXRDY interrupt so it seems to work now.

     

    Thanks a lot, John!

     

    Regards,

    Christoph

    (topic closed, I think ...)

    0
    Comment actions Permalink
  • Avatar
    John Franklin

    You're very welcome Christoph. I also have lost count of the number of times I've forgotten something crucial. Usually I have a vague feeling I've been here before, which just adds to the frustration. 

    Regards,

    John

    0
    Comment actions Permalink

Please sign in to leave a comment.