Shop OBEX P1 Docs P2 Docs Learn Events
Starting a new cog Question. — Parallax Forums

Starting a new cog Question.

JMLStamp2pJMLStamp2p Posts: 259
edited 2008-02-28 12:00 in Propeller 1
Hello,
Please see attached "Spin" file for code.

I would like to start a new cog to run my "Recieved_Data" method. I have it declared in Main but is "commented" out until I get some advice. The rest of the code is working properly, I can enter·three "3" digit numbers into my Matrix Keypad and they will show up on my LCD. They are then transmitted out my serial port to another prop. The program then needs to run the Recieved_Data method in a loop in a seperate Cog for RF stability.

I have·recieved some advice on starting another serial port
by declaring another OBJ to use FullDuplexSerial. From what I understand a
call to FullDuplexSerial starts another Cog in itself. When I use for example:

OBJ:
·· data_LCD: "FullDuplexSerial"
·· data_Transmitter: "FullDuplexSerial"

Would this start "2" seperate Cogs, one for each call ?

I would like to use: data_LCD.start(3,2,0,19200)· for writing data to my LCD.
and:··data_Tranciever.start(1,0,0,9600) for my Tranciever as I may need to recieve data in the serial port and enter data into the LCD at the same time.
I would like to take advantage of using seperte cogs instead of relying on
buffers alone.

Thanks for your advise,
JMLStamp2p

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2008-02-27 21:46
    When you call data_LCD.start(...), that will start up a cog. When you call data_Transmitter.start(...), that will start up another cog.
    Calling data.start(...) will start a 3rd cog. I don't have copies of Numbers or Clock, so I don't know whether they use additional cogs.

    I don't know why you need a separate cog for Received_Data since your main cog stops itself right after starting up Received_Data.
    You could just call Received_Data as the last thing your main routine does (so it never gets control back after calling Received_Data).
  • JMLStamp2pJMLStamp2p Posts: 259
    edited 2008-02-28 12:00
    I understand Mike,Thanks ...

    JMLStamp2p
Sign In or Register to comment.