Problem with differential counter modules
Enrique
Posts: 90
Hello,
I am going through the Propeller Education Kit Labs but coding in C instead of Spin and I have encountered a problem in chapter 7, Counter Modules and Circuit Applications Lab.
I hooked up a LED to pin 4 and another one to pin 5 and I am trying to change their brightness using differential duty mode. When I run the program LED 4 works without any problem but LED 5 doesn't turn on at all. I checked the LED that refuses to cooperate and pin 5 of the Propeller and they both work.
Here is the code
I am attaching counter.h and counter.c for those of you who want to duplicate the problem.
Thanks,
Enrique
I am going through the Propeller Education Kit Labs but coding in C instead of Spin and I have encountered a problem in chapter 7, Counter Modules and Circuit Applications Lab.
I hooked up a LED to pin 4 and another one to pin 5 and I am trying to change their brightness using differential duty mode. When I run the program LED 4 works without any problem but LED 5 doesn't turn on at all. I checked the LED that refuses to cooperate and pin 5 of the Propeller and they both work.
Here is the code
/** * @file LedDutySweep.c * This is the main LedDutySweep program start point. */ /** * Main program function. */ #include <propeller.h> #include "pin.h" #include "counter.h" int main(void) { const int scale=16777216; int duty; int delta; // Prepare the CTRA register ctraSetMode(DUTY_DIFFERENTIAL); ctraSetApin(4); ctraSetBpin(5); pinOutput(4); pinOutput(5); delta=1; duty=100; // while(1) { waitcnt(CLKFREQ/100+CNT); FRQA=duty*scale; duty+=delta; if (duty==255) delta=-1; if (duty==100) delta=1; } return 0; }
I am attaching counter.h and counter.c for those of you who want to duplicate the problem.
Thanks,
Enrique
Comments
At first glance I don't see why there would be a problem. I trust that there is an issue of course.
Sorry my programming time is limited today (and any Wednesday). I'll try the example tomorrow if someone else doesn't get to it first.
--Steve
-Phil
The shifting didn't help.
Enrique
It works on my Prop demo board; but, because the duty cannot go lower than 100, the LED connected to pin 5 glows only very dimly and very briefly. If you let the duty go to zero, your pin 5 LED might show more enthusiasm.
-Phil
You are right, when I let duty go down to 0 both LEDs work.
Thanks,
Enrique