Accessing Pic SFRs as an array.

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.
 
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
 
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.
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…