PDA

View Full Version : Problem on sending data on serial port



bwaxing
- 2nd May 2011, 20:16
hellow everyone,

i want to send a number of words (strings) to a serial port, but when simulating the design on proteus isis,the virtual terminal to display the strings (words) of the serial port,displays words (strings) which i did not send...any help please..
code:


define OSC 20
trisb=$F8
DEFINE HSER_RCSTA 90h
DEFINE HSER_TXSTA 20h
DEFINE HSER_BAUD 2400
DEFINE HSER_SPBRG 25
main:
portb=0
if portb.3=1 then
HSEROUT ["door" ,10,13]
pause 200
HSEROUT ["opened" ,10,13,10,13]
pause 200
endif
goto main
end


simulation attached:

cncmachineguy
- 2nd May 2011, 21:46
I would start by checking the baud rate. this line:


DEFINE HSER_SPBRG 25

is the same as I use with a 48mHz OSC. Now mind you, I am just starting to get into serial so I may be way off here.

aratti
- 2nd May 2011, 22:10
Place a MAX 232 between your pic and the terminal, in your simulation, and you will receive the carrect characters.

Terminal is expecting an inverted signal (what max 232 will do, along with the level translation) and since it doesn't receive the proper signal isn't able to decode what you send.

Cheers

Al.

bwaxing
- 3rd May 2011, 18:09
I would start by checking the baud rate. this line:


DEFINE HSER_SPBRG 25

is the same as I use with a 48mHz OSC. Now mind you, I am just starting to get into serial so I may be way off here.

i've not understand you above,but i modified the code and tried to simulate it again,the results on the terminal is not what i sent.....
code:

define osc 20
char var byte
trisb=1
trisc=0
RCSTA=$90
TXSTA=$24
SPBRG=25
start:
hserin 1000,mainloop,[char]
mainloop:
if portb.3=1 then
hserout ["door is opened",13,10]
hserout [char]
endif
goto start
end


Is there another way to send data to serial port...?an example will do...

simulation results attached.

mackrackit
- 3rd May 2011, 21:05
Look at the SEROUT2 command in the manual.