Shop OBEX P1 Docs P2 Docs Learn Events
Spin code topic (simple) — Parallax Forums

Spin code topic (simple)

PridborPridbor Posts: 30
edited 2014-02-24 00:46 in Propeller 1
Can somebody please help me out with this most likely simple question?

I have spent more time than I care to admit to to find out why the first 3
SendData routine doesn't work, while the second one LED.SendData does
work perfectly.

The working one refers to an object made by Beau for the 4D Display Demo,
and I literally copied the code and entered it into my test code!

(I do have the PropBOE annd the Display working via the interconnect Beau was
nice to provide me) Been playing around quite a bit but am getting stuck on this one.

I'm also looking for another routine that sends a hex byte but that's the next problem :-)

Thanks in advance

Preben

Cmd := $010F

SendData(Cmd) ''Send 15
SendData($0000)
SendData($0F01)

LED.SendData(Cmd) ''Send 15
LED.SendData($0000)
LED.SendData($0F01)

time.Pause(500)


LED.sndhex(Cmd) '' send 115
LED.sndhex($0100)
LED.sndhex($737C)

pri SendData(Data) ''Send Word variable to the uOLED display
ser.char(Data.byte[1])
ser.char(Data.byte[0])

Comments

  • kuronekokuroneko Posts: 3,623
    edited 2014-02-22 22:17
    Looks like you are talking to two different serial devices. While there are implementations that would work under these circumstances the majority doesn't. Can you provide more info/code?
  • PridborPridbor Posts: 30
    edited 2014-02-22 23:19
    Good point although I can't quite see it I will have a look, but
    this is all the code there is, as I tried to eliminate any code which might have sent me off course

    I have attached the entire program below

    Thanks for your suggestion

    Preben

    {{
    *******************************************
    * Test programming of Display programmed *
    * in ViSi Genie *
    * uLCD(SK)-32PTU display *
    * Author: *
    * *
    *******************************************




    File: Drive LCD-32PTU
    }}
    CON

    _clkmode = xtal1 + pll16x
    _xinfreq = 5000000


    rxpin = 0
    txpin = 1
    reset = 2




    OLEDBaud = 9600





    obj
    LED : "PJ_uLCD(SK)-32PTU_v2.0"

    ser : "Parallax Serial Terminal" ''Used ONLY For DEBUGGING


    time : "Timing"


    var 'Used ONLY for DEMO

    word Cmd, Hex1, Hex2 , Hex3 , Hex4, Hex5 , Hex6
    byte Cmd1, Cmd2, Cmd3, Val1, Val2, CmdCS, CS






    pub mainDEMO


    if ina[31] == 0 '' Check to see if USB port is powered
    outa[30] := 0 '' Force Propeller Tx line LOW if USB not connected
    else
    ser.Start(19200) ''Used ONLY For DEBUGGING




    LED.start(rxpin, txpin, reset, OLEDBaud) ''Starts uOLED display


    Cmd1 := $01
    Cmd2 := $0F
    Cmd3 := $00
    Val1 := $00
    Val2 := $0F
    CS := $01



    Cmd := $010F

    SendData(Cmd) ''Send 15
    SendData($0000)
    SendData($0F01)

    LED.SendData(Cmd) ''Send 15
    LED.SendData($0000)
    LED.SendData($0F01)

    time.Pause(500)


    LED.sndhex(Cmd) '' send 115
    LED.sndhex($0100)
    LED.sndhex($737C)

    pri SendData(Data) ''Send Word variable to the uOLED display
    ser.char(Data.byte[1])
    ser.char(Data.byte[0])
  • kuronekokuroneko Posts: 3,623
    edited 2014-02-22 23:36
    Pridbor wrote: »
    ... although I can't quite see it I will have a look, but
    this is all the code there is, as I tried to eliminate any code which might have sent me off course
    The uLCD(SK)-32PTU_v2.0 driver uses the Parallax Serial Terminal (PST). Each time you include PST in your object tree you get a new instance. Which means the instance in your primary object (top level) is different from the one included by PJ_uLCD(SK)-32PTU_v2.0. Also, as both are started on the same pins they will interfere with each other. IOW right now you got what you asked for (non-working program). The top level instance currently talks to the PC (pins 31/30) while the PTU driver talks to pins 0 and 1. Which means you should see output in the terminal program on your PC. Starting both drivers on the same pins will not work.

    Is there a particular reason why you want to move SendData up one level or rather why you want to talk to the display from different objects?

    Please wrap your code in [noparse]
    
    [/noparse] tags.                        
  • PridborPridbor Posts: 30
    edited 2014-02-23 09:50
    Just a test to see if I got it right. Didn't show up in a window as the other thread I looked at,
    your same comments to him :-) Maybe due to it's small size in length and width?

    Didn't expect to include the [] thanks for the education will do in the future :-)
    'if ina[31] == 0                                         '' Check to see if USB port is powered
    '  outa[30] := 0                                         '' Force Propeller Tx line LOW if USB not connected
    'else
    '  ser.Start(19200)                                      ''Used ONLY For DEBUGGING
    
    
    
    
    LED.start(rxpin, txpin, reset, OLEDBaud)                ''Starts uOLED display
    
    
    Cmd1 := $01
    Cmd2 := $0F
    Cmd3 := $00
    Val1 := $00
    Val2 := $0F
    CS   := $01
    
    
      
    Cmd  := $010F
       
    '  SendData(Cmd)             ''Send 15
    '  SendData($0000)
    '  SendData($0F01)
    [COLOR=#333333]
    [/COLOR]
    
  • PridborPridbor Posts: 30
    edited 2014-02-23 10:12
    First of all thanks! I got it now and no reason to lift the code up other than me being lazy
    trying to avoid going between different tags and search for the small piece of code of
    interest to me.

    BUT, as mentioned I'm really looking for the routine which will do a hex byte transfer. The
    sndhex() which is just calling SendData() is sending a word and I need it to be in byte format
    such that I can create a dynamic command structure and calculate a checksum to be sent
    to the Display. I know that I can extract and do the calculation and then form a word etc but
    it seems to be a very inefficient and complex way for a simple problem, or?

    Can you propose a routine for me? I did try the "char()" which I thought that SendData() uses and also hex()
    both to no avail.

    Thanks again for taking the time

    Preben
  • kuronekokuroneko Posts: 3,623
    edited 2014-02-24 00:46
    Pridbor wrote: »
    Can you propose a routine for me? I did try the "char()" which I thought that SendData() uses and also hex() both to no avail.
    If you want to bypass existing functionality I'd simply introduce generic block transfer methods (to send data and receive optional results/ACK). They could be implemented at LCD object level or in a separate object, e.g.
    PUB send(buffer, length)
    
      repeat length
        ser.Char(byte[buffer++])
        
    PUB recv(buffer, length)
    
      repeat length
        byte[buffer++] := ser.CharIn
    
    What you put into your buffer is really up to you.
Sign In or Register to comment.