What am I doing wrong?
bboy8012
Posts: 153
Frustrated beyond believe!
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Hunger hurts, starvation works!
CON _clkmode = xtal1 + pll16x _xinfreq = 5_000_000 gpsTx = 21 gpsRx = 20 gpsBaud = 4800 'GPS Commands GetInfo = $00 GetValid = $01 GetSats = $02 GetTime = $03 GetDate = $04 GetLat = $05 GetLong = $06 GetAlt = $07 GetSpeed = $08 GetHead = $09 VAR byte info[noparse][[/noparse]2], valid[noparse][[/noparse]1], sats[noparse][[/noparse]1], time[noparse][[/noparse]3], date[noparse][[/noparse]3] word heading[noparse][[/noparse]2], speed[noparse][[/noparse]2], alt[noparse][[/noparse]2], lat[noparse][[/noparse]5], lon[noparse][[/noparse]5] OBJ uart : "Simple_Serial" debug : "FullDuplexSerial" PUB Delay(mS) waitcnt((clkfreq / 1000 * mS) + cnt) PUB main debug.start(31, 30, 0, 19200) waitcnt (1_000_000 * 25 + cnt ) uart.start(gpsRx, gpsTx, gpsBaud) waitcnt (1_000_000 * 25 + cnt ) repeat uart.tx(String("!GPS")) uart.tx(GetInfo) info := uart.rx debug.str(@info) debug.str(13) debug.str(10)
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Hunger hurts, starvation works!
Comments
SimpleSerial does not buffer any bytes, so you will generally miss data when using speeds above - say - 300 baud.
You generally use .rx in a tight loop (you have around 5 to 10 simple SPIN lines during the 9600 baud stop-bit time slot - no calling routines or such!)
You can also use a separate COG for that loop.
In that situation however you should use "FullDuplex", which does exactly that. FullDuplex can be instantiated multiple times.
---
Edit: Are you really sure, the GPS commands are binary? Would be strange...
Post Edited (deSilva) : 12/25/2007 9:31:20 AM GMT
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Hunger hurts, starvation works!
Rich
http://forums.parallax.com/forums/default.aspx?f=25&m=195562
@bboy: So most of my criticism was rather principally than to the point; what is left is:
Change:
by
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Hunger hurts, starvation works!