Finally!
At last I've been able to use USART!
On the tx side I changed serout from N2400 to T2400 and the rx started to display correct data! Data is sent 10ms after powering the txer.
99% of data is correctly showed on the display.
Now I have to mount the sensor and send acquired data along with a sort of checksum.
I could stay hours watching the display:0...1...2...3...4..... to see if some of my numbers gets lost. Watching it for a minute, no problems!
So here is the working code for the TX:
Code:
INCLUDE "modedefs.bas"
ANSEL=0
CMCON0=%00000111
define osc 4
txpin var gpio.4
led var gpio.5
power var gpio.2
i var byte
low power
loop:
for i=0 to 9
high power
pause 10
serout txpin,t2400,[$55,$55,$55,$55,$66,#i]
low power
high led
pause 30
low led
pause 1000
next i
goto loop
And, of course RX:
Code:
define OSC 20
Define LCD_LINES 4 ' Settings for a 4x20 LCD
Define LCD_DREG PORTB ' 4bit mode
Define LCD_DBIT 4 '
Define LCD_RSREG PORTB
Define LCD_RSBIT 3
Define LCD_EREG PORTB'
Define LCD_EBIT 2
DEFINE HSER_RCSTA 90h ' Enable serial port & continuous receive
DEFINE HSER_TXSTA 20h ' Enable transmit, BRGH = 0
DEFine HSER_BAUD 2400
DEFINE HSER_CLROERR 1 ' Clear overflow automatically
'LCD Lines constants
row4 con $d4
row3 con $94
row2 con $c0
row1 con $80
hser var byte
intcon=0
pause 500
lcdout $fe,1
lcdout $fe, row1, "** RX TEST **"
loop:
hserin [wait($66),hser]
hserout [#hser]
lcdout $fe, row3," hser: ",dec1 hser
goto loop
Bookmarks