![]() But, if you want to, you can Print from a Different Cog as well, as that lesson will show you. Usually, it is most convenient to call print and other such functions from the main routine, even if they need to print values updated by other cogs, as we do in this example. Print from one cog at a time, please! Print, scan and other functions that interact with the SimpleIDE Terminal can only run in one cog at a time. Add 1 for every local variable used, 2 for each function called, and 1 for each parameter and each return value used by the functions called. If you were to add more instructions to the blink function's code block, you would need to increase it. Stack Size - how much? 10 is the bare minimum value you would want to use for the stackSize parameter. void blink() // Blink function for other cog This would make the cog and its stack space unavailable for other uses afterward. If those four instructions were not in a loop, they would execute just once and the cog would shut down, but without releasing its resources. Its code block is entirely inside a while(1) loop, so it will keep on blinking that P26 LED until the power shuts off. Note that it has an empty parameter list and void return type. int main() // Main functionĬog_run(blink, 128) // Run blink in other cogīelow the main routine is the blink function itself, written to be launched into another cog without any fuss. It also provides a stack space of 128 32-bit memory locations used for performing calculations while executing the instructions in the blink code block. This launches the function defined at address blink. Inside the main routine is just one statement: cog_run(blink, 128). #include "simpletools.h" // Library include Since the blink function definition is below the main function, this lets the compiler know to expect it. Verify that the Activity Board's (original or WX version) P26 LED starts blinking.Īfter including the simpletools.h library, there is a forward declaration for the blink function.Click SimpleIDE’s Load RAM
0 Comments
Leave a Reply. |