PIC18F452 problem with USART

Discuss PIC and electronic related things

Moderators: David Barker, Jerry Messina

Post Reply
lonelyboy
Posts: 2
Joined: Thu Oct 02, 2008 8:03 pm
Location: Birmingham

PIC18F452 problem with USART

Post by lonelyboy » Fri Nov 14, 2008 8:14 pm

HI all

Can any one help me with my problem please ? I have written a simple program wich prints out a data on USART.write module .

I have tried different baud rates but I always get rubish as a result on IDE terminal in Swordfish compiler SE VERSION .

However when I print data before while loop . the data is printed out correctly . the following is my code :

Code: Select all

Device = 18F452 
Clock  = 10 


Include "USART.bas" 
Include "convert.bas" 
         
TRISC.6 = 0 // PORTC.6 AS OUTPUT 

RCSTA.7 = 1 

TXSTA.6 = 0
TXSTA.5 = 1
TXSTA.4 = 0     // asynchronous mode 
TXSTA.2 = 1     // high baud rate 

USART.SetBaudrate(br9600)


USART.Write("This is a message ",13,10)  

While TRUE 

USART.Write("This is a message ",13,10)  // This doesnt work !!!!!!!!!! 

Wend



I appreciate if someone fixes my problem .

cheers

Doj
Posts: 362
Joined: Wed Apr 11, 2007 10:18 pm
Location: East Sussex

Post by Doj » Sat Nov 15, 2008 1:51 pm

you need a delay after the write statement or check TXSTA.1 register to make sure the buffer is empty before sending a new character, you will corrupt the USART BUFFER if you send new data before old data if finished.

Post Reply