I want to send data from one PIC to another using HSEROUT/HSERIN, so as a first step I figured I would just send 1 byte and go from there. But i'm not getting the same byte out that i put in.
Transmit:
Code:
' PIC = 18F4550, 4Mhz External OSC, PLL results in OSC of 48Mhz
DEFINE OSC 48
DEFINE HSER_TXSTA 24h
DEFINE HSER_RCSTA 90h
DEFINE HSER_BAUD 2400
DEFINE HSER_SPBRG 25
DEFINE HSER_BITS 8
ADCON1=%00001111
main:
HSEROUT [$47]
pause 10000
GOTO main
Recieve
Code:
' PIC = 18F1320, 20Mhz External OSC
DEFINE OSC 20
DEFINE HSER_TXSTA 24h
DEFINE HSER_RCSTA 90h
DEFINE HSER_BAUD 2400
DEFINE HSER_SPBRG 25
DEFINE HSER_BITS 8
DEFINE HSER_CLROERR 1
ADCON1=%01111111
DEFINE LCD_DREG PORTA
DEFINE LCD_DBIT 0
DEFINE LCD_RSREG PORTB
DEFINE LCD_RSBIT 2
DEFINE LCD_EREG PORTB
DEFINE LCD_EBIT 3
DEFINE LCD_BITS 4
DEFINE LCD_LINES 2
DEFINE LCD_COMMANDUS 2000
DEFINE LCD_DATAUS 50
PAUSE 500
data_in VAR BYTE
LCDOUT $FE,1,$FE,2
main:
data_in=0
HSERIN 500,main,[data_in]
LCDOUT HEX data_in," "
GOTO main
Some tests:
Code:
sent recvd
$47 $F9
$01 $F8
$FF $FF
$E9 $FE
$AA $FE
I'm lost as to what i've done wrong. Any ideas?
*edit* it must be something wrong with my transmit code, because using SEROUT2 instead on the transmit side works - but i need to use HSEROUT. Still lost.
Bookmarks