If anyone's using the PPS module I posted in the thread http://www.sfcompiler.co.uk/forum/viewtopic.php?t=1459, I've updated the code and posted it on the wiki under the User Modules (http://www.sfcompiler.co.uk/wiki/pmwiki ... lPinSelect)
The revised code is smaller, somewhat simpler, and supports all the J series parts that have a PPS module.
I changed the 'assign_input()' sub to a macro so that you no longer need to pass the address of the RPINR register, just the register name itself. The assign_output() routine changed slightly, but I left the calling convention the same so that now the syntax of the two calls match.
Peripheral Pin Select Module
Moderators: David Barker, Jerry Messina
-
- Swordfish Developer
- Posts: 1473
- Joined: Fri Jan 30, 2009 6:27 pm
- Location: US
-
- Swordfish Developer
- Posts: 1473
- Joined: Fri Jan 30, 2009 6:27 pm
- Location: US
-
- Swordfish Developer
- Posts: 1473
- Joined: Fri Jan 30, 2009 6:27 pm
- Location: US
Re: Peripheral Pin Select Module
I've updated the PeripheralPinSelect user module (V1.3) to include support for the J94 and J99 family.
These parts use a different PPS peripheral (PPS Lite) that functions similar to the PIC24 series with multiple settings per register, so the module needed significant changes in order to support them. There are now separate input pin and output pin definitions, and function names. The usage is pretty similar to the previous version, but it will require changes to your source if using the old version.
The assign_input() and assign_output() routines are done as macros, and this is probably a good example of where using a macro vs a sub has advantages. The code for the J94 version of those routines has some 100+ lines of source each, but they result in a single line of code when the macro is processed.
I noticed some errors in the Microchip header files that this info came from (I know, shocker huh?) and have hopefully fixed those, but I only spot checked some of the devices so it's likely I introduced some of my own. If you run across any, let me know.
These parts use a different PPS peripheral (PPS Lite) that functions similar to the PIC24 series with multiple settings per register, so the module needed significant changes in order to support them. There are now separate input pin and output pin definitions, and function names. The usage is pretty similar to the previous version, but it will require changes to your source if using the old version.
The assign_input() and assign_output() routines are done as macros, and this is probably a good example of where using a macro vs a sub has advantages. The code for the J94 version of those routines has some 100+ lines of source each, but they result in a single line of code when the macro is processed.
I noticed some errors in the Microchip header files that this info came from (I know, shocker huh?) and have hopefully fixed those, but I only spot checked some of the devices so it's likely I introduced some of my own. If you run across any, let me know.
-
- Swordfish Developer
- Posts: 1473
- Joined: Fri Jan 30, 2009 6:27 pm
- Location: US
Re: Peripheral Pin Select Module
PeripheralPinSelect user module (V1.4) updated to include support for the K40 family.
These devices are a bit different than the J series. Instead of being able to map functions to any RPx pin you're limited to a fixed pair of PORT registers (ie PORTA/PORTB, PORTB/PORTD, etc), but you can pick the pin in the port. Different functions have different port mapping selections, so if you plan on using one watch out and be sure to check out the PPS limitations.
The assign_input macro is different for the K40 devices. For these you get to specify the port and the pin number like so:
One thing the macro currently does NOT do is verify that the function can actually be mapped to the port you've selected. For that you're on your own.
These devices are a bit different than the J series. Instead of being able to map functions to any RPx pin you're limited to a fixed pair of PORT registers (ie PORTA/PORTB, PORTB/PORTD, etc), but you can pick the pin in the port. Different functions have different port mapping selections, so if you plan on using one watch out and be sure to check out the PPS limitations.
The assign_input macro is different for the K40 devices. For these you get to specify the port and the pin number like so:
Code: Select all
pps.assign_input(INT0PPS, PPS_PORTA, 4) // assigns INT0 input to RA4
pps.assign_input(RX1PPS, PPS_PORTB, 2) // assigns usart RX1 input to RB2
Last edited by Jerry Messina on Mon Dec 26, 2016 2:54 pm, edited 1 time in total.
Reason: download updated for 4xJ50 omissions
Reason: download updated for 4xJ50 omissions