Sub Ser_Init
#define baud 417 ;the us delay for 2400 baud rate
#define SerTxHigh Set GPIO.1 off
#define SerTxLow Set GPIO.1 On
dir GPIO.1 out
dir GPIO.0 in
SerTxHigh ;Initial RS232 idle state
end sub
sub XMIT_PRINT (PrintData$)
PrintLen = PrintData(0)
if PrintLen = 0 then exit sub
'Write Data
for SysPrintTemp = 1 to PrintLen
XMIT_RS232(PrintData(SysPrintTemp))
next
end sub
Sub XMIT_RS232(Xmit_Byte)#NR
SerTxLow ;Start bit
wait baud us
For cntr = 1 to 8
Rotate Xmit_Byte Right
If Status.C ON Then SerTxHigh
If Status.C Off Then SerTxLow
wait baud us
Next
SerTxHigh ;Stop bit
wait baud us
end sub
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Will this send "test" to hyperterminal
#chip 12F675, 4 'mhz
#config OSC=INTOSC, MCLRE=off, WDT=off
Ser_Init
start:
XMIT_PRINT(test)
wait 5 sec
goto start
Sub Ser_Init
#define baud 417 ;the us delay for 2400 baud rate
#define SerTxHigh Set GPIO.1 off
#define SerTxLow Set GPIO.1 On
dir GPIO.1 out
dir GPIO.0 in
SerTxHigh ;Initial RS232 idle state
end sub
sub XMIT_PRINT (PrintData$)
PrintLen = PrintData(0)
if PrintLen = 0 then exit sub
'Write Data
for SysPrintTemp = 1 to PrintLen
XMIT_RS232(PrintData(SysPrintTemp))
next
end sub
Sub XMIT_RS232(Xmit_Byte)#NR
SerTxLow ;Start bit
wait baud us
For cntr = 1 to 8
Rotate Xmit_Byte Right
If Status.C ON Then SerTxHigh
If Status.C Off Then SerTxLow
wait baud us
Next
SerTxHigh ;Stop bit
wait baud us
end sub
Use the quotes for strings, XMIT_PRINT("test").
For some forgotten reason, do not invert SerTxHigh and SerTxLow. Use:
#define SerTxHigh Set GPIO.1 on
#define SerTxLow Set GPIO.1 Off