Ryan Mystique - 2008-08-02

Here is what i have, running through a max232, i need to fix the part of "SerReceive 1, Temp" right after start so that it will work with the communiation method I'm using, Feel free to point out any other errors.

#chip 12F675, 12 'mhz
#config  MCLRE=off, WDT=off
       
Ser_Init
dim test as Word
dim test1 as word
dim name as word

Dir GPIO.0 in
Dir GPIO.1 Out
Dir GPIO.2 in
Dir GPIO.3 In

start:

SerReceive 1, Temp
        If Temp = 50 Then goto start
        If Temp = 52 Then output
    Temp = 50

goto start

sub output
test = ReadAD10(AN0)
Bin2ascii (test_H)
Bin2ascii (test)

test1 = ReadAD10(AN2)
Bin2ascii (test1_H)
Bin2ascii (test1)

end sub

Sub Ser_Init
#define baud 833 ;the us delay for 1200 baud rate 
#define SerTxHigh Set GPIO.1 on
#define SerTxLow Set GPIO.1 Off
SerTxHigh ;Initial RS232 idle state
#define RecAHigh GPIO.3 on
#define RecALow GPIO.3 off
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

sub Bin2ascii(LCDValue )#NR 
SERCEN = 0 
SERDEC = 0 
SERUN = 0 
LCDValueTemp = 0  
If LCDValue >= 100 Then
LCDValueTemp = LCDValue / 100 
SERCEN = LCDValueTemp + 48
Xmit_RS232(SerCen) 'SerSend (1,SERCEN) 
LCDValue = LCDValue - LCDValueTemp * 100 
end if 
IF LCDValueTemp > 0 OR LCDValue >= 10 then 
LCDValueTemp = LCDValue / 10 
SERDEC = LCDValueTemp + 48 
Xmit_RS232(Serdec) 'SerSend (1,SERDEC)
LCDValue = LCDValue - LCDValueTemp * 10 
end if 
SERUN = LCDValue + 48 
Xmit_RS232(Serun) 'SerSend (1,SERUN)
end sub