SERIN Timing Troubles
val veirs
Posts: 1
I can read my GPS output at 4800 baud just fine when running the SX-Key debugger but SERIN does not reliably return values when the program is compiled without the debugger. (I uploaded the 12/20 SXB.exe program.) It seems that the timing must have some 'difficulties' that show up only with the compiled code.
Does anyone have any suggestions?
Here is my code:
' This program listens on RB.0 for "L" and blinks LED's
'
' Device Settings
'
DEVICE SX28, OSC4MHZ, TURBO, STACKX, OPTIONX
FREQ 4_000_000
'
' IO Pins
'
GPS VAR RB.0
LED0 VAR RA.0 'LEDs put on RA bits for DEBUGGING
LED1 VAR RA.1
'
' Variables
'
dat VAR Byte
dat0 VAR Byte
' =========================================================================
PROGRAM Start
' =========================================================================
' Subroutines / Jump Table
'
' Use: GOSUB to parse serial input string
Get_Ser_Str:
LED1 = 0
getFirst_L:
SERIN GPS, N4800, dat
LED1=0
if dat = "L" then chk_LL
GOTO getFirst_L
chk_LL:
LED1 = 1
RETURN
'
' Program Code
'
Start:
'Initialize
';Configure port settings
\ mov !ra,#%11111100 ;Port A.bits 0 & 1 output dir.
'
Run:
gosub Get_Ser_Str
LED0 = 1 'blink LED on RA.0
PAUSE 200
LED0 = 0
PAUSE 200
GOTO Run
END
Does anyone have any suggestions?
Here is my code:
' This program listens on RB.0 for "L" and blinks LED's
'
' Device Settings
'
DEVICE SX28, OSC4MHZ, TURBO, STACKX, OPTIONX
FREQ 4_000_000
'
' IO Pins
'
GPS VAR RB.0
LED0 VAR RA.0 'LEDs put on RA bits for DEBUGGING
LED1 VAR RA.1
'
' Variables
'
dat VAR Byte
dat0 VAR Byte
' =========================================================================
PROGRAM Start
' =========================================================================
' Subroutines / Jump Table
'
' Use: GOSUB to parse serial input string
Get_Ser_Str:
LED1 = 0
getFirst_L:
SERIN GPS, N4800, dat
LED1=0
if dat = "L" then chk_LL
GOTO getFirst_L
chk_LL:
LED1 = 1
RETURN
'
' Program Code
'
Start:
'Initialize
';Configure port settings
\ mov !ra,#%11111100 ;Port A.bits 0 & 1 output dir.
'
Run:
gosub Get_Ser_Str
LED0 = 1 'blink LED on RA.0
PAUSE 200
LED0 = 0
PAUSE 200
GOTO Run
END
Comments
By the way, you can change:
\ !RA, #%11111100
to:
TRIS_A = %11111100
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
Dallas Office
Even if you use "IRC_CAL IRC_4MHZ" the internal RC varies greatly over temperature.
You can use any frequency resonator you have handy (4mhz and above), just be sure to change the FREQ line.
Bean.
Post Edited (Bean) : 12/27/2004 9:13:45 PM GMT