serial comm from Pic to STAMP


Closed Thread
Results 1 to 2 of 2
  1. #1
    d1camero's Avatar
    d1camero Guest

    Question serial comm from Pic to STAMP

    Hello, I am new to uProcs, Pics and PicBasic, but things are going well.

    I am using SEROUT2 to communicate with a Basic STAMP and it appears to work well, but the STAMP only receives every second transmission. I hooked a scope to the serial line, and yes, the PIC is transmitting correctly.

    Here is the PicBasic Code:
    <code><b>
    @ Device PIC12F675,WDT_OFF,PWRT_ON,PROTECT_OFF,MCLR_ON,BOD_ OFF 'sets configuration

    INCLUDE "modedefs.bas"

    Serial VAR gpio.2
    Stuff VAR word

    TRISIO = %00000000 ' Set all ports to output
    CMCON = %00000111 ' Disable Comparators
    ANSEL = %00000000 ' Turn off all ADC

    Pause 1000 ' Wait to allow Hardware to Settle

    gpio = %00000000

    ' Loop, sending a value out on the serial line
    Stuff = 0
    testloop:
    stuff = stuff + 1
    serout2 Serial, 16780, ["Value:", DEC Stuff]
    PAUSE 1000
    goto testloop

    END
    </b></code>


    And here is the BASIC Stamp code:

    <code><b>

    '{$STAMP BS2}
    '{$PBASIC 2.5}
    INPUT 0

    Value VAR Word
    Waits VAR Word

    Waits = 0

    DO
    DEBUG HOME
    DEBUG "Waiting... ", DEC Waits, CR
    SERIN 0, 16780, [WAIT("Value:"), DEC Value]
    DEBUG "Got Value. Value=", DEC Value
    Waits = Waits + 1
    LOOP


    END
    </b>
    </code>

    Any ideas?

    thanks
    d1

  2. #2
    d1camero's Avatar
    d1camero Guest


    Did you find this post helpful? Yes | No

    Default

    Found the problem: with the SERIN command, when expecting a number, it will read ASCII numbers until a non-numerical ASCII code is discovered. Since I did not put a CR on the end of the SEROUT2 data, the STAMP reads the number, then waits for the next non-decimal ASCII - which is the next transmission. The remainder of the transmission is tossed, because the stamp is then waiting for "Value:"

    d1

Similar Threads

  1. Pic to pic interrupt ans serial comm
    By ronjodu in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 10th May 2008, 22:43
  2. High Speed Serial Comm PC - PIC and PIC - PIC
    By manumenzella in forum mel PIC BASIC Pro
    Replies: 23
    Last Post: - 16th January 2007, 21:55
  3. Big characters on HD44780 4x20
    By erpalma in forum mel PIC BASIC Pro
    Replies: 23
    Last Post: - 7th January 2007, 02:21
  4. pc to pic serial comm and i2c eeprom
    By elektroline in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 2nd November 2006, 05:51
  5. Serial Pic to Pic using HSER
    By Chadhammer in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 11th March 2005, 23:14

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts