Prop Basis & Tasks
TimH
Posts: 48
I've just started playing with a QuickStart board and PropBasic so I'm at the flashing LED's stage.
I want to start 2 tasks (running in separate cogs) each one flashing a different LED.
Here's my very simple test code:
DEVICE P8X32A, XTAL1, PLL16X
FREQ 80_000_000
'FLASHES LED'S ON THE QUICKSTART BOARD
PROGRAM Start
'Define Tasks
Led_Flash1 TASK
Led_Flash2 TASK
Start:
COGSTART Led_Flash1
COGSTART Led_Flash2
END
TASK Led_Flash1
LED1 PIN 16 OUTPUT
High LED1
PAUSE 500
LOW LED1
ENDTASK
TASK Led_Flash2
LED2 PIN 17 OUTPUT
HIGH LED2
PAUSE 500
LOW LED2
ENDTASK
I get errors when I compile with PropBasic. Anyone have any input - I read all material on this I can find.
I want to start 2 tasks (running in separate cogs) each one flashing a different LED.
Here's my very simple test code:
DEVICE P8X32A, XTAL1, PLL16X
FREQ 80_000_000
'FLASHES LED'S ON THE QUICKSTART BOARD
PROGRAM Start
'Define Tasks
Led_Flash1 TASK
Led_Flash2 TASK
Start:
COGSTART Led_Flash1
COGSTART Led_Flash2
END
TASK Led_Flash1
LED1 PIN 16 OUTPUT
High LED1
PAUSE 500
LOW LED1
ENDTASK
TASK Led_Flash2
LED2 PIN 17 OUTPUT
HIGH LED2
PAUSE 500
LOW LED2
ENDTASK
I get errors when I compile with PropBasic. Anyone have any input - I read all material on this I can find.
Comments
keep the questions coming
best regards
Stefan
I don't do PropBASIC, yet but:
1) it appears the TASK definitions need to be outside the Program definition. Thsi got rid of the compile error and cause some valid SPIN to be generated.
2) your Flasher tasks needed to loop, otherwise, they just turned on the LED and left.
The code above blinks 2 LEDs on my QuickStart board on 1/2 second, off 1/2 second.
Happy coding!!
That compiles -- I realized I had missed the loop in the tasts, but thought should still compile. I will try on my QuickStart tonight.