Hi Dave
Have been reading the very interesting HSER info form all over.
Let's say that I have the PIC's connected as follows :
PIC 16F887 -- PIC 18F4520 -- PC(com port)
At PIC 16F887 the code is
Code:
'USART defines and register settings begin here - use for HSERIN/OUT
RCSTA = $90 ' Enable serial port & continuous receive
TXSTA = $20 ' Enable transmit, BRGH = 0
SPBRG = 51 ' 2400 Baud @ 8MHz, 0.17%
DEFINE HSER_RCSTA 90h ' Enable serial port & continuous receive
DEFINE HSER_TXSTA 20h ' Enable transmit, BRGH = 0
DEFINE HSER_SPBRG 51 ' 2400 Baud @ 8MHz, 0.17%
DEFINE HSER_CLROERR 1 ' Clear overflow automatically
' Check port settings PORTC.6 = TX and PORTC.7 = RX
' For PIC to PIC TX to RX C.6 to C.7 and visa versa
' Don't forget TRISC=%10000000
'USART defines and register settings end here
main: 'tx loop begins
high LED ' LED on
Pause 1000 ' Delay for 1 seconds
HSERout "9",DEC 3,$d,$a
low LED ' LED off
pause 1000
goto main
On the 18F4520 (middleman RX and TX PIC in my setup)
Code:
'USART defines and register settings begin here - use for HSERIN/OUT
RCSTA = $90 ' Enable serial port & continuous receive
TXSTA = $20 ' Enable transmit, BRGH = 0
SPBRG = 51 ' 2400 Baud @ 8MHz, 0.17%
DEFINE HSER_RCSTA 90h ' Enable serial port & continuous receive
DEFINE HSER_TXSTA 20h ' Enable transmit, BRGH = 0
DEFINE HSER_SPBRG 51 ' 2400 Baud @ 8MHz, 0.17%
DEFINE HSER_CLROERR 1 ' Clear overflow automatically
' Check port settings PORTC.6 = TX and PORTC.7 = RX
' For PIC to PIC TX to RX C.6 to C.7 and visa versa
' Don't forget TRISC=%10000000
'USART defines and register settings end here
main: 'tx and rx loop begins here
high LED 'LED on
Pause 1000 ' delay for 1 second
'HSER lines begine here
HSERIN [WAIT("9"),DEC NET] '<< this is the format for the receiver or if you're looping
LCDOUT $fe,1
LCDOUT "I received the number .." DEC NET
HSERout "I received the number",DEC NET,$d,$a 'data to COM port on pc
'HSER lines end here
goto main
end
And on the PC hyperterminal or MCS serial tool is waiting to receive and/or send back to PIC
Have I got it right ?
Kind regards
Dennis
Bookmarks