While loop problem starting new cog
spinbob
Posts: 27
First a few details. Program written in spin, converted to C with spin2cpp. 12K of code compiles without errors. Our unit (custom PCB) has a display on a I2C bus that I use for feedback as to code running. Here is the problem:
In the Main() I do this:
Init a new cog to gather data which is in another C file. In the new cog I init a couple variables then sit in a while(1) loop reading the A/D and storing values. This is where the trouble lies. If I remove the while loop then the rest of the code in my Main works fine but with the while loop in place the unit hangs up, no display. All this code runs fine in it's spin form.
Thanks
In the Main() I do this:
Init a new cog to gather data which is in another C file. In the new cog I init a couple variables then sit in a while(1) loop reading the A/D and storing values. This is where the trouble lies. If I remove the while loop then the rest of the code in my Main works fine but with the while loop in place the unit hangs up, no display. All this code runs fine in it's spin form.
Thanks
Comments
Don't know but if you looking for those variables' got to pass them somehow
int32_t Spin_Start()
{
thisobj.Cog = (cognew(Spin_Main(), (int32_t)(&thisobj.Stack)) + 1);
return 0;
}
int32_t Spin_Main()
{
thisobj.K1 = 2;
while (1) {
// Spin_Calculate();
}
return 0;
}
c:/propgcc/propeller-elf/include
@spinbob, you will have to re-write your spin program to run a PASM cog instead of a Spin cog. Or you could modify the generated C++ code to use pthread_create instead of cognew.