So very frusturated with MPLab. Anyway, I am just starting out learning how to program microcontrollers, and im pretty new to C and assembly too. I am trying to make an LED dim via PWM and while I know if I look on the web I can find a super great effecient way of doing it, I like to try and figure things out for myself first. So I wrote the following block of code to try and get things going:
Well the problem is that I will build the project, then I will start debugging by stepping into the code. After about 4 clicks or so the green arrow will hit the TurnOnLed(&TRISB,100); line of code, and the next time I click "step into", the green arrow dissapears for a split second, but reappears on the same line! It will NOT actually proceed into the function itself.
I have tried rebooting my computer, rebuilding it from scratch with a new project, changing the code around a tiny bit, but no matter what execution will not proceed past the point where I call the function.
Does anyone have any ideas? I don't even know if that function would work to dim an LED, it seems like it would when I worked the logic out in my head but I have a tendency to not get very simple logical things, letalone create them myself.
Rich (BB code):
#include <pic18.h>
TurnOnLed(char *Led,int brightness);
void main(void)
{
PORTB = 0b00000000;
while (1)
{
TurnOnLed(&TRISB,100);
}
}
TurnOnLed(char *Led,int brightness)
{
*Led = 0b00000000; // turn it on
for(int b=brightness;b=0;b--) // wait brightness cycles
{ }
*Led = 0b11111111; // turn it off
for(int b=100-brightness;b=0;b--) // wait 100 - brightness cycles
{ }
}
I have tried rebooting my computer, rebuilding it from scratch with a new project, changing the code around a tiny bit, but no matter what execution will not proceed past the point where I call the function.
Does anyone have any ideas? I don't even know if that function would work to dim an LED, it seems like it would when I worked the logic out in my head but I have a tendency to not get very simple logical things, letalone create them myself.