In SX Microcontrollers, SX/B Compiler and SX-Key Tool, LanceRasmussen wrote: I'm trying to just parrot out the serial information (in at TTL and out at CMOS) and detecting and managing 4 buttons. When I connected the GPS device to the serial out directly, it properly is showing at 4800 in hyperterminal. I see the NEMA codes But when going through this code, I'm getting gibberish. Suggestions? Thanks ahead of time. Lance ' ========================================================================= ' ' File...... LANCEGPS.SXB ' Author.... Lance Rasmussen ' E-mail.... [url=lance@lance.ws]lance@lance.ws[/url] ' Started... ' Updated... 10 APR 2008 ' ' ========================================================================= ' ---------------------------------------------------------------------- ' Program Description ' ---------------------------------------------------------------------- ' ---------------------------------------------------------------------- ' Device Settings ' ----------------------------------------------------------------------- DEVICE SX28, OSC4MHZ, TURBO, STACKX, OPTIONX FREQ 4_000_000 ID "KEYPAD" ' ---------------------------------------------------------------------- ' IO Pins ' ---------------------------------------------------------------------- 'RC7Unused PIN RC.7 OUTPUT 'RC6Unused PIN RC.6 OUTPUT 'RC5Unused PIN RC.5 OUTPUT 'RC4Unused PIN RC.4 OUTPUT RC7Unused PIN RC.7 OUTPUT NShutter PIN RC.6 OUTPUT PULLUP RC5Unused PIN RC.5 OUTPUT NMeter PIN RC.4 OUTPUT PULLUP KeyD PIN RC.2 INPUT SCHMITT PULLUP ' Remote receiver D KeyC PIN RC.1 INPUT SCHMITT PULLUP ' Remote receiver C KeyB PIN RC.3 INPUT SCHMITT PULLUP ' Remote receiver B KeyA PIN RC.0 INPUT SCHMITT PULLUP ' Remote receiver A RB7Unused PIN RB.7 OUTPUT PULLUP RB6Unused PIN RB.6 OUTPUT PULLUP RB5Unused PIN RB.5 OUTPUT PULLUP RB4Unused PIN RB.4 OUTPUT PULLUP RB3Unused PIN RB.3 OUTPUT PULLUP RB2Unused PIN RB.2 OUTPUT PULLUP 'RB1Unused PIN RB.1 OUTPUT PULLUP 'RB0Unused PIN RB.0 OUTPUT PULLUP TX PIN RB.1 OUTPUT ' Serial out at 4800 RX PIN RB.0 INPUT ' from GPS RAUnused PIN RA OUTPUT ' ---------------------------------------------------------------------- ' Constants ' ---------------------------------------------------------------------- Yes CON 0 ' active low input No CON 1 Pressed CON 1 GpsBaud CON "T4800" ' to/from GPS module ' ---------------------------------------------------------------------- ' Variables ' ---------------------------------------------------------------------- tmpW1 VAR Word tmpB0 VAR Byte ' subroutine vars temp1 VAR Byte ' subroutine vars temp2 VAR Byte ' subroutine vars temp3 VAR Byte ' subroutine vars char VAR Byte ' vars ' ====================================================================== PROGRAM Start ' ====================================================================== ' ---------------------------------------------------------------------- ' Subroutine Declarations ' ---------------------------------------------------------------------- DELAY SUB 1, 2 ' delay in milliseconds GPSRX SUB ' get byte from GPS GPSTX SUB 1 ' send byte from GPS ' ---------------------------------------------------------------------- ' Program Code ' ---------------------------------------------------------------------- Start: RA = 0 RB = %00000011 RC = %00000000 NMeter = No NShutter = No Main: GPSRX ' IF KeyA = Pressed then DO GPSRX ' LOOP UNTIL KeyA <> Pressed NMeter = Yes GPSRX ' PAUSE 200 GPSRX ' NShutter = Yes PAUSE 300 NShutter = No NMeter = No ENDIF IF KeyB = Pressed then DO GPSRX ' LOOP UNTIL KeyB <> Pressed PAUSE 10000 NMeter = Yes GPSRX ' PAUSE 200 GPSRX ' NShutter = Yes PAUSE 300 NShutter = No NMeter = No ENDIF IF KeyC = Pressed then DO GPSRX ' LOOP UNTIL KeyC <> Pressed NMeter = Yes GPSRX ' PAUSE 200 GPSRX ' NShutter = Yes PAUSE 4000 NShutter = No NMeter = No ENDIF IF KeyD = Pressed then DO GPSRX ' LOOP UNTIL KeyD <> Pressed PAUSE 3000 GPSRX ' NMeter = Yes PAUSE 200 GPSRX ' NShutter = Yes PAUSE 200 NShutter = No NMeter = No ENDIF GOTO Main ' ---------------------------------------------------------------------- ' Subroutine Code ' ---------------------------------------------------------------------- ' --------------------------------------------------------------------- ' Use: DELAY ms ' -- 'ms' is delay in milliseconds, 1 - 65535 DELAY: IF __PARAMCNT = 1 THEN tmpW1 = __PARAM1 ' save byte value ELSE tmpW1 = __WPARAM12 ' save word value ENDIF PAUSE tmpW1 RETURN ' Use: theByte = GPSRX GPSRX: SERIN RX, GpsBaud, temp1 ' get byte from 406a SEROUT TX, GpsBaud, temp1 ' repeat byte out to serial output RETURN GPSTX: ' SEROUT TX, GpsBaud, __PARAM1 ' Send byte to serial output RETURN ' ====================================================================== ' User Data ' ====================================================================== ---------- End of Message ---------- You can view the post on-line at: http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=263268 Need assistance? Send an email to the Forum Administrator at forumadmin@parallax.com The Parallax Forums are powered by dotNetBB Forums, copyright 2002-2008 (http://www.dotNetBB.com)