Atmel website | ARM Community | AVR freaks | Technical Support
Banner
 FAQ •  Search •  Register •  Login 

All times are UTC + 1 hour [ DST ]




Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: Unexpected behavior on USART0 transmit
PostPosted: Sun Jul 04, 2010 8:38 pm 
Offline

Joined: Mon Jan 11, 2010 4:37 pm
Posts: 36
Hello, I am trying to create a manual outgoing buffer for the USART0 on my AT91SAM9261.

What I do is handle the functions

sendchar('h');
sendchar('e');
sendchar('l');
sendchar('l');
sendchar('o');

with the code below. The problem is that I only get the last letter, because the lower branch is never firing, because TXRDY is always high. And when I trace through, I verify that TXRDY does *not* go low when I write something to the transmit holding register.

Isn't it supposed to go low, for exactly this purpose?

Like I said, it seems as if I'm overwriting my outgoing holding register before it can get processed, since I'm only getting the last character.

Any thoughts (or sample code) would be greatly appreciated.

Thanks very much in advance.

Code:

void USART0_sendchar(unsigned char c)
{
 
  AT91_USART0_IDR = TXRDY_BIT;   // disable this interrupt
 
  if (AT91_USART0_CSR && TXRDY_BIT)
  {
    // the transmitter is ready, don't bother with buffer
    AT91_USART0_THR = c;     
  }
  else
  {
    // transmitter is not ready, place it on the buffer
    // we handle buffer full by ignoring add'l input
   
    if (usart0_tx_counter < USART0_BUFFER_SIZE)
    {   
      usart0_tx_buffer[usart0_tx_idx] = c;
      usart0_tx_idx++;
      usart0_tx_idx %= USART0_BUFFER_SIZE;
      usart0_tx_counter++;     
    }
   
   
  }
   
  AT91_USART0_IER = TXRDY_BIT;   // enable this interrupt
}


Top
 Profile  
 
 Post subject: Re: Unexpected behavior on USART0 transmit
PostPosted: Thu Jul 08, 2010 4:07 am 
Offline

Joined: Mon Jan 11, 2010 4:37 pm
Posts: 36
Really at91.com? 47 views and nobody noticed that I used '&&' instead of '&'? Obviously nobody is even reading these.

What is with this site?


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC + 1 hour [ DST ]


Who is online

Users browsing this forum: Bing [Bot] and 11 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to: