Page 2 of 2

Re: RPOR15bits.RP30R = 1; meaning

PostPosted: Thu Jul 11, 2019 7:56 am
by Manoj
Though I am using system clock.//OC1CON1bits.OCTSEL = 0b111;
Say I am using timer 3 for now .
Then when TMR3=pR3 timer rolls over.
So now what technique should I use ?
//This one definitely does no work
if(TMR3==pR3)
{
OC1RS =25000;
OC1R = (25000/2);
}

Re: RPOR15bits.RP30R = 1; meaning

PostPosted: Thu Jul 11, 2019 8:04 am
by ric
Use the TMR3 rollover interrupt.

Re: RPOR15bits.RP30R = 1; meaning

PostPosted: Fri Jul 12, 2019 10:06 am
by Manoj
Ok I did it. Now its stable
Code:-
void __attribute__((__interrupt__, auto_psv)) _ADC1Interrupt( void )
{
if (IFS0bits.AD1IF)
{
IFS0bits.AD1IF = 0;
if (FReadings==AVGNO)
{
// PWMpreiod=16000000/(c*64);
OC1RS = (int)(PWMpreiod-1); // PWM period
OC1R = (int)((PWMpreiod/2)-1 ); //50% initial duty cycle
FilterFlag=FALSE;
}
}
Thanks.

Re: RPOR15bits.RP30R = 1; meaning

PostPosted: Wed Jul 17, 2019 12:48 pm
by Manoj
When I am using Dso to view the PWM ,It is shaking a lot .Is this supposed to Happen?
Thank you.

Re: RPOR15bits.RP30R = 1; meaning

PostPosted: Thu Jul 18, 2019 2:23 am
by AussieSusan
You don't need to test the IF flag inside the ISR - it will ONLY be called when the IF (and IE) flags are (both) set.
Susan

Re: RPOR15bits.RP30R = 1; meaning

PostPosted: Fri Jul 26, 2019 10:02 am
by Manoj
Ok it worked.