EmbeddedRelated.com
Forums

AT92SAM7_Lib using USART transmit interrupt

Started by dclapp01 March 22, 2005


I am trying to use the AT92SAM7 library to implement a uputs to
USART0, but I am having a hard time getting the transmit interrupt
going. All the samples I can find on the AT91 CD trigger output when
a receive character comes in (I get interrupts when I receive), but
there is no documentation on how do I start transmit, and handle hte
interupt until my buffer is transmitted.

Am I ment to use hte FRAMING - I can find no detailed documentation
on the libraty to describe this.

Any input would be helpful.

Thanks!




Re: AT92SAM7_Lib using USART transmit interrupt
Re: AT92SAM7_Lib using USART transmit interrupt
I just did this the other day... let's see if I can find my code...

Ok, here we go. I don't really like how it works in this chip, but I guess
it gets the job done. The interrupt is supposed to be level-triggered, not
edge-triggered. It'll generate interrupts as long as it's ready to transmit
and the TXRDY interrupt is enabled. My code enables TXRDY whenever it's got
something queued to be sent, and when the ISR sees TXRDY set in the CSR, it
sends the next character in the queue (puts it in THR). If there's nothing
left to send, it disables the TXRDY interrupt.

I was going nuts trying to figure out why the RXRDY interrupt wasn't firing.
Turns out I fried the TX driver on my PC's com port somehow. Oops. I guess
that's why they give you two ports.

Scott
----- Original Message -----
From: "dclapp01" <>
To: <>
Sent: Tuesday, March 22, 2005 8:36 AM
Subject: [AT91SAM7] AT92SAM7_Lib using USART transmit interrupt > I am trying to use the AT92SAM7 library to implement a uputs to
> USART0, but I am having a hard time getting the transmit interrupt
> going. All the samples I can find on the AT91 CD trigger output when
> a receive character comes in (I get interrupts when I receive), but
> there is no documentation on how do I start transmit, and handle hte
> interupt until my buffer is transmitted.
>
> Am I ment to use hte FRAMING - I can find no detailed documentation
> on the libraty to describe this.
>
> Any input would be helpful.
>
> Thanks! >
> Yahoo! Groups Links




Hi,
 
Your RX/TX ISR is pretty straight forward (PS : I prsume your PIOA pins are set
properly for UxTXD ?) :
 
1.    Read US0_CSR/US1_CSR into a local buffer, clears the INT, let's call it 'status'.
2.    Check if 'status' has US_TXRDY set. If set, getdata from ring TX buffer, and write it to
       US0_THR.
       If you've sent the last char, clear bit US_TXRDY in US0_IDR (clear TX Interrupt)
3.    Check for errors (I just write US_RSTA to get rid of them - if there at all)
4.    Check if US_RXRDY is set in 'status'.
       If so buffer read an RX char from US0_RHR/US1_RHR to say, 'ch'.
         Now can process on 'ch' eg. whether to store or not etc.
5.    Manage the wrapping, depth of RX ring buffer like handshaking etc.
 
That's it for a function you can call seprately from an ISR.....
 
B rgds
Kris
 
>
> I am trying to use the AT92SAM7 library to implement a uputs to
> USART0, but I am having a hard time getting the transmit interrupt
> going.  All the samples I can find on the AT91 CD trigger output when
> a receive character comes in (I get interrupts when I receive), but
> there is no documentation on how do I start transmit, and handle hte
> interupt until my buffer is transmitted.
>
> Am I ment to use hte FRAMING - I can find no detailed documentation
> on the libraty to describe this.
>
> Any input would be helpful.
>
> Thanks!>
>
>      
>           
>     
>     > --------
> Yahoo! Groups Links
>
>   a.. To

Hmmm, this looks to easy!

I will give this a try - I think I was on the right path, but I was
trying to use the higher up level stuff from the library- i.e.
AT91F_US_PutChar (USART_pt, myChar);

What I will try and do then:

1)Create my own transmit buffer
2) in my "uputs"
a) Copy my characters to my transmit buffer
b) put the first character to go out in US0_THR
c) Enable TX interrupts
3) in my ISR Handle things the way you suggested

What is the best way to enable/disable interrupts on the fly? I need
to differentiate between enabling interrupts and clearing the
interrupt? I was trying to use

AT91F_US_EnableIt(COM0,AT91C_US_TIMEOUT | AT91C_US_FRAME |
AT91C_US_OVRE |AT91C_US_RXRDY | AT91C_US_TXRDY);

to enable interrupts.

Thanks for you input!! --- In , "microbit" <microbit@c...> wrote:
> Hi,
>
> Your RX/TX ISR is pretty straight forward (PS : I prsume your PIOA
pins are set
> properly for UxTXD ?) :
>
> 1. Read US0_CSR/US1_CSR into a local buffer, clears the INT,
let's call it 'status'.
> 2. Check if 'status' has US_TXRDY set. If set, getdata from ring
TX buffer, and write it to
> US0_THR.
> If you've sent the last char, clear bit US_TXRDY in US0_IDR
(clear TX Interrupt)
> 3. Check for errors (I just write US_RSTA to get rid of them -
if there at all)
> 4. Check if US_RXRDY is set in 'status'.
> If so buffer read an RX char from US0_RHR/US1_RHR to
say, 'ch'.
> Now can process on 'ch' eg. whether to store or not etc.
> 5. Manage the wrapping, depth of RX ring buffer like handshaking
etc.
>
> That's it for a function you can call seprately from an ISR.....
>
> B rgds
> Kris
>
> >
> > I am trying to use the AT92SAM7 library to implement a uputs to
> > USART0, but I am having a hard time getting the transmit
interrupt
> > going. All the samples I can find on the AT91 CD trigger output
when
> > a receive character comes in (I get interrupts when I receive),
but
> > there is no documentation on how do I start transmit, and handle
hte
> > interupt until my buffer is transmitted.
> >
> > Am I ment to use hte FRAMING - I can find no detailed
documentation
> > on the libraty to describe this.
> >
> > Any input would be helpful.
> >
> > Thanks!
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> > ------------------------------
--------------
> > Yahoo! Groups Links
> >
> > a.. To
> >
> >




Thanks,

See my response to "microbit", I think I am close, but I am trying to
use higher level "library" calls.

--- In , "Scott Miller" <scott@o...> wrote:
> I just did this the other day... let's see if I can find my code...
>
> Ok, here we go. I don't really like how it works in this chip, but
I guess
> it gets the job done. The interrupt is supposed to be level-
triggered, not
> edge-triggered. It'll generate interrupts as long as it's ready to
transmit
> and the TXRDY interrupt is enabled. My code enables TXRDY whenever
it's got
> something queued to be sent, and when the ISR sees TXRDY set in the
CSR, it
> sends the next character in the queue (puts it in THR). If there's
nothing
> left to send, it disables the TXRDY interrupt.
>
> I was going nuts trying to figure out why the RXRDY interrupt
wasn't firing.
> Turns out I fried the TX driver on my PC's com port somehow.
Oops. I guess
> that's why they give you two ports.
>
> Scott
> ----- Original Message -----
> From: "dclapp01" <dclapp01@y...>
> To: <>
> Sent: Tuesday, March 22, 2005 8:36 AM
> Subject: [AT91SAM7] AT92SAM7_Lib using USART transmit interrupt > >
> >
> >
> > I am trying to use the AT92SAM7 library to implement a uputs to
> > USART0, but I am having a hard time getting the transmit interrupt
> > going. All the samples I can find on the AT91 CD trigger output
when
> > a receive character comes in (I get interrupts when I receive),
but
> > there is no documentation on how do I start transmit, and handle
hte
> > interupt until my buffer is transmitted.
> >
> > Am I ment to use hte FRAMING - I can find no detailed
documentation
> > on the libraty to describe this.
> >
> > Any input would be helpful.
> >
> > Thanks!
> >
> >
> >
> >
> >
> >
> >
> >
> >
> > Yahoo! Groups Links
> >
> >
> >
> >
> >
> >
> >
> >