Hi guys!
I recently bought a "Clicker 2 mikro bus" from Mikroelektronika. This comes with a 16-bit PIC24FJ1024GB610 microcontroller:
I'm able to communicate and load .HEX files in it. I loaded it up with a "Led Blinking" program on PORT B and worked too.
My problem is when I try to get a PWM signal out of it. For the moment: their PWM_Start() function seems to do nothing.
Then, I tried to program it "old school" fashion. Yet, nothing comes out of PIN # RF2. See below:
void PWMStep (void){
int PWMperiod=799;
TRISFbits.TRISF2 = 0; //Set RF2 as output
RPOR15bits.RP30R = 18; //OC1 Output to Pin PWM
LATFbits.LATF2 = 0; //Initialize RF2 as low
OC1CON1 = 0; // Clear registers
OC1CON2 = 0;
OC1CON2bits.SYNCSEL = 0b11111; // synchronized by itself
OC1CON1bits.OCTSEL = 0b111; // system clock is the source for output Compare
OC1CON1bits.OCM = 0b111;
OC1CON1bits.OCSIDL=1;
OC1RS = (int)(PWMperiod); // PWM period
OC1R = (int)((PWMperiod/2)); //50% initial duty cycle
}
void main(){
while(1){
PWMStep();
}
}
I tried this simple program just to get a 50% duty cycle PWM signal. For the moment, RF2 keeps a LOW state. No PWM at all.
Any help is appreciated. Many thanks,
RF Can
I recently bought a "Clicker 2 mikro bus" from Mikroelektronika. This comes with a 16-bit PIC24FJ1024GB610 microcontroller:
I'm able to communicate and load .HEX files in it. I loaded it up with a "Led Blinking" program on PORT B and worked too.
My problem is when I try to get a PWM signal out of it. For the moment: their PWM_Start() function seems to do nothing.
Then, I tried to program it "old school" fashion. Yet, nothing comes out of PIN # RF2. See below:
void PWMStep (void){
int PWMperiod=799;
TRISFbits.TRISF2 = 0; //Set RF2 as output
RPOR15bits.RP30R = 18; //OC1 Output to Pin PWM
LATFbits.LATF2 = 0; //Initialize RF2 as low
OC1CON1 = 0; // Clear registers
OC1CON2 = 0;
OC1CON2bits.SYNCSEL = 0b11111; // synchronized by itself
OC1CON1bits.OCTSEL = 0b111; // system clock is the source for output Compare
OC1CON1bits.OCM = 0b111;
OC1CON1bits.OCSIDL=1;
OC1RS = (int)(PWMperiod); // PWM period
OC1R = (int)((PWMperiod/2)); //50% initial duty cycle
}
void main(){
while(1){
PWMStep();
}
}
I tried this simple program just to get a 50% duty cycle PWM signal. For the moment, RF2 keeps a LOW state. No PWM at all.
Any help is appreciated. Many thanks,
RF Can