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: Send string to USART with AT91SAM7S64
PostPosted: Fri Dec 03, 2010 2:19 am 
Offline

Joined: Fri Dec 03, 2010 1:54 am
Posts: 1
Hi, all
I want to send long string to SAM7S64 USART port. But some characters are missing
My code:

void InitUSART0(void)
{

u_pPio->PIO_PDR = BIT5 | BIT6 ; //Disables the PIO from controlling the corresponding pin (enables peripheral control of the pin).
u_pPio->PIO_ASR = BIT5 | BIT6 ; //Assigns the I/O line to the Peripheral A function.
u_pPio->PIO_BSR = 0; //Assigns the I/O line to the Peripheral B function.


//enable the clock of USART
u_pPMC->PMC_PCER = 1<<AT91C_ID_US0;

//set baud rate divisor register
u_pUSART0->US_BRGR = 313; //((48000000)/9600x16)

//write the Timeguard Register
u_pUSART0->US_TTGR = 0;

//Set the USART mode
u_pUSART0->US_MR = 0x08c0; // 8-bit mode, no parity, normal mode

//Enable the RX and TX PDC transfer requests
u_pPDC0->PDC_PTCR = AT91C_PDC_TXTEN | AT91C_PDC_RXTEN;

//Enable usart
u_pUSART0->US_CR = 0x50;

}

void write_char_USART0(unsigned char ch)
{
while (!(u_pUSART0->US_CSR&AT91C_US_TXRDY)==1);
u_pUSART0->US_THR = ((ch & 0x1FF));
}

void write_str_USART0(unsigned char* buff) {

unsigned int i = 0x0;

while(buff[i] != '\0') {
write_char_USART0(buff[i]);
i++;
}

}

Maybe this is a problem of main clock or PLL configuration ?

Thanks.


Top
 Profile  
 
 Post subject: Re: Send string to USART with AT91SAM7S64
PostPosted: Fri Dec 03, 2010 5:02 am 
Offline

Joined: Sat Oct 30, 2010 6:04 pm
Posts: 574
Or at the receiving end perhaps? What are you using as a terminal application? I'd generally recommend RealTerm, capturing in "Direct" mode (ie to a file, not the screen+file).

9600 baud is relatively slow, and oscillator/PLL timings tend to be far more stable/accurate than baud generators from decades past.

Have you examined the bit spacing on an oscilloscope? How about data sent from the receiver end.

Closely packed data can be a challenge for some receivers, sometimes using 2 stop-bits can help with inter-symbol separation.

If you are sending ASCII 8-bit data (unsigned char), why mask with 0x1FF? You'd be better casting and masking with 0xFF.


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: No registered users and 4 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: