PPS programming during operation

Thread Starter

MaxHeadRoom

Joined Jul 18, 2013
28,617
Anyone familiar with the PPS feature of some of the newer Picmicro's.
Is it possible to change an output pin designation, for example a few times in a program, or must it be carried out only at reset time?
Also with some later Pic's, the *.INC & Template files do not seem to be available, is this due to Micrichip dropping assembly aimed documentation?
 

Thread Starter

MaxHeadRoom

Joined Jul 18, 2013
28,617
16f18313.
Yeah, I read the article, but it did not seem to confirm, one way or another?
Also, it looks like MPLB X is not really that Assembly friendly?
Too bad, because I cannot use the above pic with IDE 8.92.
It defiantly looks like Picmicro is dissuading those using assembly.
 

LesJones

Joined Jan 8, 2017
4,174
Hi Max, I have only changed pin designations near the start of a program.
This is the code that I used.
Code:
;Init PPS 
    MOVLW    0x0F        ; Value obtained from table 16-3 of the PIC16F18446 datasheet
    BANKSEL    RB4PPS        ;Set TX to PORTB bit 4
    MOVWF    RB4PPS
    MOVLW    0x0E        ; Value obtained from table 16-2 of the PIC16F18446 datasheet
    BANKSEL    RX1PPS        ;Set RX to PORTB bit 6
    MOVWF    RX1PPS
    
[code/]

For output pins the PPS register used is the one related to the pin that is being used as the output.
For input pins the PPS register is the one related to the signal that is being moved.
I can't see why changes can't be made later in the program. 
I remember when I first used it I found it difficult to understand.

Les.
 

nsaspook

Joined Aug 27, 2009
13,079
Yes, you can reconfigure PPS digital pins on the fly.
PIC16(L)F18313/18323 DS40001799E-page 142  2015-2018 Microchip Technology Inc. 13.0 PERIPHERAL PIN S

When the PPS1WAY bit is clear, the PPSLOCKED bit of the PPSLOCK register can be cleared and set multiple times during code execution, but requires the PPS lock/unlock sequence to be performed each time modifications to the PPS registers are made.
http://ww1.microchip.com/downloads/en/DeviceDoc/PIC16-L-F18313_18323-Data-Sheet-40001799E.pdf

I highly recommend requiring locks to change PPS registers.
 

Thread Starter

MaxHeadRoom

Joined Jul 18, 2013
28,617
Yes, you can reconfigure PPS digital pins on the fly.
Just to clarify, I wish to swap the PWM output between 3 outputs in different points in the program, (one of them is the already assigned pin) do you need to declare them as outputs when reverting or after swapping?
Due to requiring to use a pic that has this feature, I have to go to MPLAB X and I seem to remember it is not Assembly friendly! :(
Thanks.
 

John P

Joined Oct 14, 2008
2,025
I've written code for PIC16F parts which requires the PPS status to be changed regularly during operation. To answer Max, I made a PIC control 8 hobby servos using a single PWM module, where each of 8 outputs had a turn delivering a high level (1 to 2 msec out of a 20msec time frame), and the PWM was placed on each of the 8 output pins in turn.

You have a choice of unlocking PPS just once after reset, or being able to unlock it and re-lock it over and over, or leaving it unlocked all the time. It depends on how you feel the need for safety versus convenience.

I've also found it useful to use PPS to place the UART RX and TX functions on the same pin. That's for communication via RS-485, where the data line can only be used in one direction anyway, so you might as well have a single pin doing both receive and transmit. Saving a port pin is always good!

I don't know whether the status of the pin as input or output gets changed along with a change in function via PPS. I'd call that a "try it and see" feature, if you can't get information from the data sheet. With my 8 servos, the pins were always outputs, so that problem didn't occur.

(Edited to answer Max, who posted at the same time as I did.)
 
Last edited:

geekoftheweek

Joined Oct 6, 2013
1,201
In case you run into it again down the road again you can use XC8 for assembly. I haven't tried it yet, but did have to use XC16 and found it pretty much the same as MPASM. There were some standard library and C options that needed deselecting to make it work the same... it just added some stuff to set up memory and the stack for a C type program. The config settings didn't quite seem to work the same, but I just put them into a separate C source file and everything worked out.

https://ww1.microchip.com/downloads/en/DeviceDoc/MPLAB XC8 PIC Assembler User's Guide 50002974A.pdf
 

Thread Starter

MaxHeadRoom

Joined Jul 18, 2013
28,617
As far as i have found out so far, the ver V5.35 and older only work with the MPASM, after these ver, a new form of assembler was used making it difficult to program in assembly.
 

JohnInTX

Joined Jun 26, 2012
4,787
Apparently one needs to load the older (V5.35) of MPASM X to program in the old 8.92 ver Assembly. :rolleyes:
I poked around in a few versions of MPLABX using MPASM. MPLABX versions 5.10 with MPASM 5.82 through MPLABX 5.35 with MPASM 5.87 look like they support 16F18313 using a variety of development tools PICkit 4, ICD 3/4 and RealICE. I'd lean towards 5.35 even though it whines about MPASM going away. Maybe a version in between.

IMHO if you can stay in MPASM you're better off.

Good luck!

EDIT: fewer development tools supported in 5.10
 
Last edited:

JohnInTX

Joined Jun 26, 2012
4,787
Yeah, I have removed the latest version and am trying V5.35, later ver's do not seem to have the *.INC files I need.
FWIW up to at least 5.40 MPLABX, you can have multiple versions installed at once. I have a folder on the desktop with a subfolder for each version. Drag and drop the shortcuts to the IDE and IPE from the current version to the subfolder e.g. Desktop->MPLABX->Ver5_10. When you install the next version it will put shortcuts again on the desktop. Drag those into another subfolder. Rinse and repeat.
 

Thread Starter

MaxHeadRoom

Joined Jul 18, 2013
28,617
Just becoming familiar with the transition from MASM IDE 8.92 to MASM X 5.35 & Pickit3 , I used an older chip on hand 12f1822 to flash a LED for a test and worked OK.
Using virtually the same program for 16F18313 compiles and programs OK, but no LED flash result.
Internal OSC 1Mhz
May be missing something for the new chip?

Edit:
False Alarm.
Problem solved!
 
Last edited:
Top