Wait for a string on a serial port


Results 1 to 20 of 20

Threaded View

  1. #7
    Join Date
    Aug 2006
    Location
    SWITZERLAND (french speaking)
    Posts
    952


    Did you find this post helpful? Yes | No

    Default Do I send data with the correct syntax?

    Hi,

    I'm trying to do almost the same as RuudNL but I'm having some trouble to make it work.

    From the Serial Communicator (MECANIQUE), using a FTDI TTL232R serial cable, I send a command identifier and a value to the PIC.

    Code:
    ' ====== FUSES ====================================================================================
    ' PIC 12F683
    @ __CONFIG _FCMEN_OFF &_IESO_OFF &_BOD_OFF &_CPD_OFF &_CP_OFF &_MCLRE_OFF &_PWRTE_OFF &_WDT_OFF &_HS_OSC
    
    ' ====== REGISTERS ================================================================================
    ' Registers   76543210
    ANSEL      = %00000000  'Disable analog inputs
    ADCON0     = %00000000  'ADC is OFF
    CMCON0     = %00000111  'Comparator is OFF
    OPTION_REG = %10000000  'Pull-Ups disabled
    TRISIO     = %00000001  'Inputs/Outputs
    GPIO       = %00000000  'High/Low
    
    ' ====== DEFINES ==================================================================================
    DEFINE OSC 8
    
    ' ====== VARIABLES ================================================================================
    TX_ON  var GPIO.2 'LED
    DataIn var GPIO.0
    Switch var byte
    BdRate var WORD
              
    ' ====== INITIALIZE ===============================================================================
    TX_ON  = 0
    Switch = 0
    BdRate = 49236 '9600 OIN
    
    ' ====== PROGRAM ==================================================================================
    MAIN:
        SERIN2 DataIn,BdRate,[WAIT("Identifier"),Switch]
        IF Switch = 1 THEN TX_ON = 1
        IF Switch = 0 THEN TX_ON = 0
        GOTO MAIN
    END
    Unfortunately, the PIC doesn't react to the incoming data.

    I might not use the correct syntax in the Serial Communicator.

    Do I have to type something different as this here:
    Name:  2017-08-13-Serial Communicator.jpg
Views: 1284
Size:  35.1 KB

    Thanks for any help.
    Last edited by flotulopex; - 13th August 2017 at 19:47.
    Roger

Similar Threads

  1. How to Serial comm. wait for a string?
    By elcrcp in forum mel PIC BASIC Pro
    Replies: 8
    Last Post: - 29th December 2015, 11:25
  2. wait for a string
    By sahin5002 in forum mel PIC BASIC Pro
    Replies: 11
    Last Post: - 3rd April 2009, 00:27
  3. grabbing a serial string and passing it
    By cpayne in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 4th March 2006, 00:39
  4. Serial String parsing
    By DynamoBen in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 29th June 2005, 19:11
  5. serial string parsing
    By billybobbins in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 8th September 2004, 22:34

Members who have read this thread : 2

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