Accessing Pic SFRs as an array.

Status
Not open for further replies.

Pommie

Well-Known Member
Most Helpful Member
I've been playing around with a pic again and needed to access the PPS SFRs located sequentially in memory at 0xF18. The first one is RB0PPS and to access them as an array you can do,
((unsigned char *)&RB0PPS)[7]=0x01;
This would write 1 to RB7PPS. This would enable the CLC1 output on RB7.

Well, I found it useful.

Mike.
 
I tell you what.... I have just repositioned SPI 1, 2 and 3 on a pic24... The PPS is a bit of a mine field..

I have 31 RP pins trying to fathom them out is a task!! All done though...
 
PPS is indeed a minefield. I tend to move just the bit I need (input or output) and the above was to move CCP1's output to RB0 through RB7.

Mike.
 
Yet another reason I like the CCS compiler - just tell it what peripheral pin allocations you want & it sets the appropriate registers:
C:
#PIN_SELECT U1TX = PIN_B4
#PIN_SELECT U1RX = PIN_B15
 
On the pic24 they have a locking mechanism for the PPS in the OSCCON reg... BUT!! they have a write enable sequence for the OSCCON register... AARRGGHH..

But I have it sussed
 
Yet another reason I like the CCS compiler - just tell it what peripheral pin allocations you want & it sets the appropriate registers:
C:
#PIN_SELECT U1TX = PIN_B4
#PIN_SELECT U1RX = PIN_B15
Yes, the code configurator will do that but accessing them as an array is much more flexible.

Mike.
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…