Shop OBEX P1 Docs P2 Docs Learn Events
SERIN Timing Troubles — Parallax Forums

SERIN Timing Troubles

val veirsval veirs Posts: 1
edited 2004-12-27 16:22 in General Discussion
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

Comments

  • Jon WilliamsJon Williams Posts: 6,491
    edited 2004-12-27 15:40
    The reason is you're using the internal RC oscillator an it's just not accurate enough -- I have run into the same troubles. Change your OSC settings to XT2 and use an external 4 MHz ceramic resonator; problem will be solved.

    By the way, you can change:

    \ !RA, #%11111100

    to:

    TRIS_A = %11111100

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
    Dallas Office
  • BeanBean Posts: 8,129
    edited 2004-12-27 16:22
    Jon is correct.
    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
Sign In or Register to comment.