Debug in Char, BS2_Functions, No recive permant cog lockup
So I am trying to get a char that has been sent from the PST terminal.
In the past this has worked, I cant seem to figure out what is going on...
I get nothing on the screen showing a recived byte, it just seems to perma hang.
Here is the Idea behind the test program, I know the cog is running becuase the LCD screen shows "ON", When it recives a char, it should then transmit it to the LCD Screen, letting me know it is working.
·So any ideas on what is going on?
TJ
·
In the past this has worked, I cant seem to figure out what is going on...
I get nothing on the screen showing a recived byte, it just seems to perma hang.
Here is the Idea behind the test program, I know the cog is running becuase the LCD screen shows "ON", When it recives a char, it should then transmit it to the LCD Screen, letting me know it is working.
'Started by
Var
Stack5[noparse][[/noparse]100]
Pub Run
'' Other setup sutff
cognew(Datain,@stack5)
Pub Datain | Input
lcd.init(27, 9600, 4)
lcd.cls
lcd.str(string("ON"))
bs2.start(31,30)
repeat
input := bs2.debugin_char
lcd.putc(input)
if input == "S"
Transmit := true
if input == "E"
Transmit := false
if input == "Z"
'' Save sensor zero point.
if input == "M"
'' Start manual control mode.
if input == "C"
'Save compass calibration.
'' The bs2 function calls this
PUB DEBUGIN_CHAR : ByteVal
{{
Accepts a single serial character (byte) on DEBUGIN_Pin at 9600 Baud
Will cause cog-lockup while waiting without a cog-watchdog (see example)
x := BS2.DEBUGIN_Char
BS2.DEBUG_Char(x)
}}
ByteVal := SERIN_CHAR(DEBUGIN_PIN,DEBUG_BAUD,DEBUG_MODE,8)' Send character using SEROUT_Char
'Which then calls
PUB SERIN_CHAR(pin, Baud, Mode, Bits) : ByteVal | x, BR
{{
Accepts asynchronous character (byte) on defined pin, at Baud, in Mode for #bits
Mode: 0 = Inverted - Normally low Constant: BS2#Inv
1 = Non-Inverted - Normally High Constant: BS2#NInv
x:= BS2.SERIN_Char(5,DEBUG_Baud,BS2#NInv,8)
BS2.Debug_Char(x)
BS2.Debug_DEC(x)
}}
BR := 1_000_000 / Baud ' Calculate bit rate
dira[noparse][[/noparse]PIN]~ ' Set as input
waitpeq(Mode << PIN, |< PIN, 0) ' Wait for idle
waitpne(Mode << PIN, |< PIN, 0) ' WAit for Start bit
pause_us(BR*100/90) ' Pause to be centered in 1st bit time
byteVal := ina[noparse][[/noparse]Pin] ' Read LSB
If Mode == 1
Repeat x from 1 to Bits-1 ' Number of bits - 1
pause_us(BR-70) ' Wait until center of next bit
ByteVal := ByteVal | (ina[noparse][[/noparse]Pin] << x) ' Read next bit, shift and store
else
Repeat x from 1 to Bits-1 ' Number of bits - 1
pause_us(BR-70) ' Wait until center of next bit
ByteVal := ByteVal | ((ina[noparse][[/noparse]Pin]^1)<< x) ' Read next bit, shift and store
·So any ideas on what is going on?
TJ
·
