Here are some working code snippets. This is from a standalone monitor which records the data into eprom and downloads to a Pocket PC when requested. it can also work live online to a standard PC. Unfortunately I do not have the VB code for the PC's as this is kept by my software guy. Embedded code is the territory of the hardware engineer.
set registers:-
INTCON=$80 '# sets global interrupt
OPTION_REG=$C0 '# sets RB.0 interrupt to positive edge
TXSTA=$24 '# sets transmit status register
RCSTA=$90 '# sets receive staus register
SPBRG=$81 '# sets baud rate register for 9600 baud
PIE1=$20 '# enables usart receive intertupt
rs232: '# This is the RS232 comms protocol
INTCON=$80
hserin 100,commerr2,[commin1]
if (commin1="*") then goto rigdata
if (commin1="=") then
hserin 20,answer,[commin1]
if (commin1<>"$") then goto commerr2
answer:
hserout ["OK",carret,newlin]
hserin 2000,commerr2,[commin1]
if (commin1="$") then
hserout [serial1,serial2,dec serial3,carret,newlin]
hserin 2000,commerr2,[commin2]
if (commin2="+") then
The registers are at the top of the code check the book for values. The remainder is the first part of the comms protocol. Here the decision is made as to what type of host is connected and the correct action taken(reroute for online(rigdata). In the case of the Pocket PC download the unit replies with its serial number, the rest of the code covers some classified stuff but what I have given you should put you on the right path. NOTE that I am setting the interrupt register directly as there can be latency problems using the PBP ENABLE INTERRUPT and DISABLE
INTERRUPT commands.
Best of luck and happy coding.
Bob
Bookmarks