SPI engine and cog questions
Jonathan
Posts: 1,023
Hi All,
Just a·few quick question about the SPI engine and cogs.
If I have two cogs each accessing a device using the SPI engine, do I have 4 cogs running (2X shiftin, 2x shiftout)?
Does one stop call, like spi.stop kill both cogs (shiftin and shiftout)? Or do I need to call both shiftin/out with a -1 param?
Is there an easy way to see how many cogs you have running at any particular time? Or do I need to flag each cog?
Thanks!
Jonathan
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
www.madlabs.info - Home of the Hydrogen Fuel Cell Robot
Just a·few quick question about the SPI engine and cogs.
If I have two cogs each accessing a device using the SPI engine, do I have 4 cogs running (2X shiftin, 2x shiftout)?
Does one stop call, like spi.stop kill both cogs (shiftin and shiftout)? Or do I need to call both shiftin/out with a -1 param?
Is there an easy way to see how many cogs you have running at any particular time? Or do I need to flag each cog?
Thanks!
Jonathan
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
www.madlabs.info - Home of the Hydrogen Fuel Cell Robot
Comments
Each instance of the SPI engine can control one device and you can change from one device (set of pins) to another with each call to SHIFTIN and SHIFTOUT. If you need to control two devices simultaneously, you can declare two instances of the SPI engine like: OBJ spi1, spi2 : "SPI Engine"
You could alternatively declare an array of SPI engines like: OBJ spi : "SPI Engine"
Each name or array element is a separate instance, has its own VAR data storage, and will start its own cog to do the work independently.
There is no easy way to see how many cogs you have running. There is a small utility program in the Object Exchange that attempts to start new cogs until the COGNEW fails, then stops the ones it started and reports the number of cogs it was able to start.
Thanks for the help, that answers my questions very nicely. Appreciate your time as always!
Jonathan
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
www.madlabs.info - Home of the Hydrogen Fuel Cell Robot
Excellent explanation.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Beau Schwabe
IC Layout Engineer
Parallax, Inc.