Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

picbasic USART problems

Status
Not open for further replies.

glen

New Member
Im trying to do some simple serial interfacing using a 18F252. I have never used the USART port before and I just want to test it by displaying some text on my PC using a terminal program (terminal - the old one). Im writing code using proton picbasic but cant get it to work. I just get junk on the screen. It seems like a config problem (wrong baud rate, parity, etc) but ive tried every combination with no luck. Heres the code. Any help would be great!

device 18F252
declare XTAL 20
delayms 50
ADCON1 = $07 ' Set port A to
ADCON0 = $0 ' Turns off
CCP1CON = $00 ' Turn off CCP2CON CCP2CON = $00

SPBRG = 129
Declare HSERIAL_RCSTA = %10000000 ' Enable serial port no error
Declare HSERIAL_TXSTA = %00100100 ' Enable transmit mode high

dim num as float
num = 3.14

start:

delayms 1000
hrsout "serial tester"
delayms 1000
hrsout dec num

goto start



END
 
Do you have a MAX232 driver between PIC and PC ?
 
Just tested it here with the PDS SerialCommunication windows and it's working fine @9600 baud as you defined it.

As other suggested, make sure you have a Max232 (or else inverter) between your PIC and your PC.
 
Inverter hey? I knew I was doing something wrong. I havent tried it yet but Im sure that will fix it. Thanks for the help!
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top