Shop OBEX P1 Docs P2 Docs Learn Events
Led On Communication — Parallax Forums

Led On Communication

lolobondlolobond Posts: 14
edited 2011-04-26 21:56 in Propeller 1
Hi, I am a beginner in spin language and I would appreciate ideas on how to write a spin language code that expects to receive a number '1' from a matlab program and after receiving the number turns on a led of the PE microcontroller. This is my way to confirm that there is communication between MATLAB and the propeller chip.

Thank You

Comments

  • ProcessingData...ProcessingData... Posts: 208
    edited 2011-04-25 08:38
    Below is some simple code that worked for me on using FullDuplexSerialPlus an a demoboard
    CON
    
      _clkmode = xtal1 + pll16x
      _xinfreq = 5_000_000
      
    rx = 31
    tx = 30
    
    baud = 9600
    OBJ
    ser   : "FullDuplexSerialPlus"
    
    PUB main  |  Number
    
    ser.Start(rx, tx, 0, baud)
    waitcnt(clkfreq+cnt)
    
    repeat
      Number := ser.rx
      if Number == "1"
        dira[16]~~
        outa[16]~~
    
  • lolobondlolobond Posts: 14
    edited 2011-04-25 09:43
    Thank You! I will try it soon and let you know how it did. Do you know if it can be used for FullDuplexSerial? I don't have the FullDuplexSerialPlus program included on the files that the parallax software has.
  • RS_JimRS_Jim Posts: 1,768
    edited 2011-04-26 06:06
    FullDuplexSerial is readily available on OBEX.
    Jim
  • lolobondlolobond Posts: 14
    edited 2011-04-26 21:56
    It is not working. Does it matter if what I expect to receive from Matlab is a numeric one? Do I need to change anything? My simple Matlab code is below
    s=serial('COM3','BaudRate',9600);
    fopen(s);
    ledon=[1];
    fwrite(s,ledon)
    fclose(s);
    

    Thank You
Sign In or Register to comment.