RPOR15bits.RP30R = 1; meaning

(instructions, reset, WDT, specifications...) PIC17Cxx, PIC18Fxxx

RPOR15bits.RP30R = 1; meaning

Postby Manoj » Fri Aug 24, 2018 11:52 am

I am using pic24fj256gb110.
as I was aiming to use pwm for the first time using this mcu.
I got confused here.
RPOR15bits.RP30R = 1;// used to select the out put pin .But I can not figure out what '1' defines here.
I went htrough the datasheetand noticed 'RPOR15' & 'RP30R' are there.still dont under stand what is 1 for.
please kindly help me.
Last edited by ric on Fri Aug 24, 2018 1:10 pm, edited 1 time in total.
Reason: Moved topic from "Suggestions" to "16-Bit Core"
Manoj
 
Posts: 37
Joined: Mon Apr 09, 2018 8:01 am

Re: RPOR15bits.RP30R = 1; meaning

Postby ric » Fri Aug 24, 2018 1:16 pm

PIC24FJ256GB110 datasheet, page 138, table "TABLE 10-3: SELECTABLE OUTPUT SOURCES (MAPS FUNCTION TO OUTPUT)"
As I read that table, "1" will assign C1OUT to that pin.
Latest test project, an LED matrix display made from one reel of addressable LEDs. here
User avatar
ric
Verified identity
 
Posts: 659
Joined: Sat May 24, 2014 2:35 pm
Location: Melbourne, Australia
PIC experience: Professional 5+ years with MCHP products

Re: RPOR15bits.RP30R = 1; meaning

Postby Manoj » Tue Jul 09, 2019 5:35 am

Hello Iam using this code to get 50% PWM.
But the problem is it is not stable . its changing phase simultaneously as observed from DSO.
Code:-
TRISFbits.TRISF2 = 0; //Set RF2 as output
PORTFbits.RF2 = 0; //Initialize RF2 as low
RPOR15bits.RP30R = 18; //OC1 Output to Pin PWM
OC1CON1 = 0; // Clear registers
OC1CON2 = 0;

OC1RS = PWMpreiod-1; // PWM period
OC1R = (PWMpreiod/2)-1 ; //50% initial duty cycle
OC1CON2bits.SYNCSEL = 0b11111; //synchronized by itself
OC1CON1bits.OCTSEL = 0b111; //Peripheral clock is the source for output Compare
OC1CON1bits.OCM = 0b111;

Can any one tell me how to stabelize it?
Thank you
Manoj
 
Posts: 37
Joined: Mon Apr 09, 2018 8:01 am

Re: RPOR15bits.RP30R = 1; meaning

Postby ric » Tue Jul 09, 2019 6:12 am

Show the ENTIRE program you are testing this with.
My guess is that you have not disabled the WatchDog timer, and are getting regular resets from it.
Latest test project, an LED matrix display made from one reel of addressable LEDs. here
User avatar
ric
Verified identity
 
Posts: 659
Joined: Sat May 24, 2014 2:35 pm
Location: Melbourne, Australia
PIC experience: Professional 5+ years with MCHP products

Re: RPOR15bits.RP30R = 1; meaning

Postby Manoj » Tue Jul 09, 2019 9:25 am

Sorry, The entire program is 6000+ lines long . tell me how to disable the wacthdog please.
Some example code please..
Are u asking for this part?

//

_CONFIG3(GWRP_OFF) // GWRP_OFF : General Segment Write Protect: Writes to program memory are allowed
_CONFIG2(FNOSC_PRIPLL & FCKSM_CSECMD & POSCMOD_HS & PLL_96MHZ_ON & PLLDIV_DIV2) // Primary HS OSC with PLL, Clock Switching Enabled with Failsafe Monitor, USBPLL /2
_CONFIG1(JTAGEN_OFF & FWDTEN_OFF & ICS_PGx2 ) // JTAG off, watchdog timer off
Manoj
 
Posts: 37
Joined: Mon Apr 09, 2018 8:01 am

Re: RPOR15bits.RP30R = 1; meaning

Postby ric » Tue Jul 09, 2019 10:02 am

ok, it looks like the WDT is disabled.
If you can't solve it yourself, cut your program down to the minimum required to get the PWM going, and see if you still have the problem.
Do make sure you are not re-initialising the PWM over and over.
Latest test project, an LED matrix display made from one reel of addressable LEDs. here
User avatar
ric
Verified identity
 
Posts: 659
Joined: Sat May 24, 2014 2:35 pm
Location: Melbourne, Australia
PIC experience: Professional 5+ years with MCHP products

Re: RPOR15bits.RP30R = 1; meaning

Postby Manoj » Tue Jul 09, 2019 11:00 am

Exactly I am changing the pwm frequency inside a while loop. the frequebcy is increasing 2% every time
Manoj
 
Posts: 37
Joined: Mon Apr 09, 2018 8:01 am

Re: RPOR15bits.RP30R = 1; meaning

Postby ric » Tue Jul 09, 2019 11:11 am

So is it stable if you DON'T change it on the fly?
If yes, then the problem is how you are updating it. You really need to do that just at the end of a cycle, so the timer count has just gone back to zero.
Or, stop the peripheral, change it, and start it again.
Latest test project, an LED matrix display made from one reel of addressable LEDs. here
User avatar
ric
Verified identity
 
Posts: 659
Joined: Sat May 24, 2014 2:35 pm
Location: Melbourne, Australia
PIC experience: Professional 5+ years with MCHP products

Re: RPOR15bits.RP30R = 1; meaning

Postby Manoj » Thu Jul 11, 2019 6:00 am

What do you exactly mean by end of the cycle?
Do you mean to update it at the end of the while loop.
By stoping the peripheral do you mean
T3CONbits.TON=0;
OC1CON1 = 0; // Clear registers
OC1CON2 = 0;
and strat again with new values
Manoj
 
Posts: 37
Joined: Mon Apr 09, 2018 8:01 am

Re: RPOR15bits.RP30R = 1; meaning

Postby ric » Thu Jul 11, 2019 6:12 am

Manoj wrote:What do you exactly mean by end of the cycle?
Do you mean to update it at the end of the while loop.

No. I mean right when the timer that the PWM peripheral is using has rolled over back to zero.
That is the "start" of the PWM cycle.
If you change the PWM at any other point in time, then you add jitter.
Also, if you don't reset the timer to zero when you update the PWM parameters, you risk setting a compare value that is smaller than the current timer count, which will give you one 100% cycle.

If you are just setting the PWM to keep outputting a static value, then you can be careless about precisely WHEN you set everything.
If you're trying to rapidly vary it "on the fly", then you need to understand precisely how it works, and make sure your changes are synchronised to the waveform.
Latest test project, an LED matrix display made from one reel of addressable LEDs. here
User avatar
ric
Verified identity
 
Posts: 659
Joined: Sat May 24, 2014 2:35 pm
Location: Melbourne, Australia
PIC experience: Professional 5+ years with MCHP products

Next

Return to 16-Bit Core

Who is online

Users browsing this forum: No registered users and 5 guests