JonnyMac
10-17-2011, 05:38 PM
I'm a little perplexed... I'm working on a project that sends CAN message from time to time and I want this to run as "background" process so that the main process can set flags for the required message. If I have this snippet of code in the main loop:
work := (hrs << 16) | (mns << 8) | scs
work := (work << 8) | $40
can.tx_msg(0, $91, $00, $04, @work)
... but if I move it to another Spin cog -- no go.
pri can_coms | work
repeat
if (canflags & %0000_0001)
work := (hrs << 16) | (mns << 8) | scs
work := (work << 8) | $40
can.tx_msg(0, $91, $00, $04, @work) ' does not work from bg cog
canflags := 0
term.tx("*") ' works
term.tx(CR) ' works
What's really odd is that I put a marker for FDS (called term in my test code) and that works just fine, even from the background cog. Any ideas?
And yes, I have pushed the stack size up but with no change. The CAN object is very simple, Spin-based SPI interface for MCP2515.
work := (hrs << 16) | (mns << 8) | scs
work := (work << 8) | $40
can.tx_msg(0, $91, $00, $04, @work)
... but if I move it to another Spin cog -- no go.
pri can_coms | work
repeat
if (canflags & %0000_0001)
work := (hrs << 16) | (mns << 8) | scs
work := (work << 8) | $40
can.tx_msg(0, $91, $00, $04, @work) ' does not work from bg cog
canflags := 0
term.tx("*") ' works
term.tx(CR) ' works
What's really odd is that I put a marker for FDS (called term in my test code) and that works just fine, even from the background cog. Any ideas?
And yes, I have pushed the stack size up but with no change. The CAN object is very simple, Spin-based SPI interface for MCP2515.