Strange Behaviour Propeller Mini ?
mrTheWheel
Posts: 5
Hi there,
I'm very new to this propeller things and observe strange behaviour at my first (well, second, the "Hello World" worked out of the box) learn program.
I have a Propeller Mini (very recent) and the board is set to "GENERIC"
I have altered the program "cog info exchange.c" as follows:
The expected behaviour would be a pulse with 50/50 duty cycle changing from 5Hz to 25Hz and back ... but it does not!
The duty cycle is not 50/50 and changes until it is 100/0 which is effectively a high voltage on pin 14 ....
What am I missing?
I'm very new to this propeller things and observe strange behaviour at my first (well, second, the "Hello World" worked out of the box) learn program.
I have a Propeller Mini (very recent) and the board is set to "GENERIC"
I have altered the program "cog info exchange.c" as follows:
/* Cog Info Exchange.c Example of two cogs exchanging information with a volatile global variable. The main function in cog 0 changes the value; and it affects the blink function's rate running in cog 1. http://learn.parallax.com/multicore-approaches/cores-sharing-data */ #include "simpletools.h" // Library include void blink(); // Forward declaration int *cog; // For storing process ID volatile int dt; // Declare dt for both cogs int main() // Main function { while(1) { // <<-- added this dt = 100; // Set value of dt to 100 cog = cog_run(blink, 128); // Run blink in other cog pause(2000); // Let run for 2 s dt = 20; // Update value of dt pause(2000); // New rate for 2 s } // <<-- cog_end(cog); // Stop the cog } void blink() // Function for other cog { while(1) // Endless loop { high(14); // LED on pause(dt); // ...for dt ms low(14); // LED off pause(dt); // ...for dt ms } }
The expected behaviour would be a pulse with 50/50 duty cycle changing from 5Hz to 25Hz and back ... but it does not!
The duty cycle is not 50/50 and changes until it is 100/0 which is effectively a high voltage on pin 14 ....
What am I missing?
Comments
Found it.. Stupid mistake.
The "cog = cog_run(blink, 128);" must of course be declared right before the while() statement!