![](templates/subSilver/images/CCSLogo.jpg) |
![CCS C Software and Maintenance Offers](templates/subSilver/images/forumAd6.jpg) |
View previous topic :: View next topic |
Author |
Message |
jujoab
Joined: 05 Aug 2017 Posts: 41 Location: brazil
|
pls help with PPS assigment on CCS compiler for 16LF1705 |
Posted: Sat Aug 05, 2017 8:01 pm |
|
|
I am on the move from fixed pin assignment to PPS capable PIC IC’s.
I choose the 16LF1705 as my entry point device.
After reading the “12.0 PERIPHERAL PIN SELECT (PPS) MODULE on the PIC16(L)F1705/9 manual” plus the TB3130 microchip doc, its perfectly clear how it works.
Going now to CCS compiler to implement a simple test, I do not find a way to setup the following:
1> Cannot find the way to assign a PIN to ICSPDAT and ICSPCLK. Looking at the PIC16LF1705.h file from CCS I find all kind of peripherals to attach to input or output pins, but can't find nothing similar to mentioned ICSPDAT and ICSPCLK.
2> It looks funny but have same problem with the I/O ports. How to assign an I/O port (input or output) to the physical module pins ? In both cases I can not find which symbol to use on the
pin_select ("U1TX",PIN_C4,TRUE,FALSE);
What should I use instead of "U1TX" of above example, for I/O ports (in/out) and for ICSPDAT and ICSPCLK ?
I am sure its my blindness but after searching for quite some time could not find any help.
I went to CCS examples, no luck there as well.
I appreciate help on subject.
Juan |
|
![](templates/subSilver/images/spacer.gif) |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Sat Aug 05, 2017 10:32 pm |
|
|
Look at this table, near the front of the data sheet:
Quote: | Pin Allocation Tables
TABLE 1: 14/16-PIN ALLOCATION TABLE (PIC16(L)F1705) |
It has a note at the bottom:
Quote: |
Note 1: Default peripheral input. Input can be moved to any other pin with
the PPS input selection registers |
This means the only signals that can be moved are the signals with a
superscript of "1" after the signal name. ICSPDAT and ICSPCLK do not
have the "1" after their name. You can't move them.
Quote: | How to assign an I/O port (input or output) to the physical module pins ? |
Do you mean move around pins B0, B1, A3, etc ? Like move pin B0
to pin A0 location ? You can't do that. They don't have a superscript of "1"
after their names. |
|
![](templates/subSilver/images/spacer.gif) |
Ttelmah
Joined: 11 Mar 2010 Posts: 19369
|
|
Posted: Sun Aug 06, 2017 12:48 am |
|
|
and on this bit:
Quote: |
How to assign an I/O port (input or output) to the physical module pins ? In both cases I can not find which symbol to use on the
pin_select ("U1TX",PIN_C4,TRUE,FALSE);
|
Look in the header file for the chip. This lists the peripheral pin functions that can be assigned, and the pins they can be assigned to:
Code: |
////////////////////////////////////////////////////////////////// PIN_SELECT
// #pin_select function=pin
// Valid Pins:
// PIN_A0,PIN_A1,PIN_A2,PIN_A3,PIN_A4,PIN_A5,PIN_C0,PIN_C1,PIN_C2,PIN_C3,
// PIN_C4,PIN_C5
// Input Functions:
// INT1,T0CK,T1CK,T1G,CCP1,CCP2,COGIN,SCK1IN,SCL1IN,SDI1,SDA1IN,SS1IN,U1RX,
// U1CKIN,CLCIN0,CLCIN1,CLCIN2,CLCIN3,T0CKI,T1CKI,RX1
// Output Functions:
// NULL,CLC1OUT,CLC2OUT,CLC3OUT,COGA,COGB,COGC,COGD,CCP1OUT,CCP2OUT,PWM3OUT,
// PWM4OUT,SCK1OUT,SCL1OUT,SDA1OUT,SDO1,U1TX,U1DT,C1OUT,C2OUT,PWM3,PWM4,SCK1,
// SCL1,SDA1,TX1,DT1
//
|
So (for example), CCP2OUT is the name of the CCP2 output connection, and this can be connected to pin C2, with:
Code: |
#PIN_SELECT CCP2OUT=PIN_C2
|
as a pre-processor directive.
Now the syntax you are trying to post is normally the _remapping_ syntax.
If you want, you can map peripherals to different pins later in the code, or even leave a peripheral unconnected at boot and then connect it later. However 'caveats':
1) Since the code _will_ map the peripherals that have to be assigned (such as the UART) at boot, to use this you must either not be using any default peripherals, or have the fuse 'NOPPS1WAY'. Otherwise the peripheral mappings can't be changed.
2) If you are doing several peripherals, the 'trick' is to unlock once, map all the peripherals, and then lock on the last line.
So:
Code: |
pin_select(“CCP2OUT”,PIN_A0,TRUE,FALSE); //maps CCP2OUT
pin_select("CCP1OUT",PIN_A1,FALSE); //CCP1
pin_select("PWM3OUT",PIN_A2,FALSE,TRUE); //PWM3
|
This shows how to unlock _once_ at the start of the sequence, and then re-lock at the end.
Now generally, since you will need to map things like the UART, and I2C/SSP, before using #USE RS232, #USE SPI etc., it is better and safer for have mapped these at boot, using the #PIN_SELECT syntax which unlocks once and does all the specified mappings.
Look at the sticky at the top of the forum for this. |
|
![](templates/subSilver/images/spacer.gif) |
jujoab
Joined: 05 Aug 2017 Posts: 41 Location: brazil
|
|
Posted: Sun Aug 06, 2017 12:16 pm |
|
|
Ttelmah wrote: | and on this bit:
Quote: |
How to assign an I/O port (input or output) to the physical module pins ? In both cases I can not find which symbol to use on the
pin_select ("U1TX",PIN_C4,TRUE,FALSE);
|
Look in the header file for the chip. This lists the peripheral pin functions that can be assigned, and the pins they can be assigned to:
Code: |
////////////////////////////////////////////////////////////////// PIN_SELECT
// #pin_select function=pin
// Valid Pins:
// PIN_A0,PIN_A1,PIN_A2,PIN_A3,PIN_A4,PIN_A5,PIN_C0,PIN_C1,PIN_C2,PIN_C3,
// PIN_C4,PIN_C5
// Input Functions:
// INT1,T0CK,T1CK,T1G,CCP1,CCP2,COGIN,SCK1IN,SCL1IN,SDI1,SDA1IN,SS1IN,U1RX,
// U1CKIN,CLCIN0,CLCIN1,CLCIN2,CLCIN3,T0CKI,T1CKI,RX1
// Output Functions:
// NULL,CLC1OUT,CLC2OUT,CLC3OUT,COGA,COGB,COGC,COGD,CCP1OUT,CCP2OUT,PWM3OUT,
// PWM4OUT,SCK1OUT,SCL1OUT,SDA1OUT,SDO1,U1TX,U1DT,C1OUT,C2OUT,PWM3,PWM4,SCK1,
// SCL1,SDA1,TX1,DT1
//
|
So (for example), CCP2OUT is the name of the CCP2 output connection, and this can be connected to pin C2, with:
Code: |
#PIN_SELECT CCP2OUT=PIN_C2
|
as a pre-processor directive.
Now the syntax you are trying to post is normally the _remapping_ syntax.
If you want, you can map peripherals to different pins later in the code, or even leave a peripheral unconnected at boot and then connect it later. However 'caveats':
1) Since the code _will_ map the peripherals that have to be assigned (such as the UART) at boot, to use this you must either not be using any default peripherals, or have the fuse 'NOPPS1WAY'. Otherwise the peripheral mappings can't be changed.
2) If you are doing several peripherals, the 'trick' is to unlock once, map all the peripherals, and then lock on the last line.
So:
Code: |
pin_select(“CCP2OUT”,PIN_A0,TRUE,FALSE); //maps CCP2OUT
pin_select("CCP1OUT",PIN_A1,FALSE); //CCP1
pin_select("PWM3OUT",PIN_A2,FALSE,TRUE); //PWM3
|
This shows how to unlock _once_ at the start of the sequence, and then re-lock at the end.
Now generally, since you will need to map things like the UART, and I2C/SSP, before using #USE RS232, #USE SPI etc., it is better and safer for have mapped these at boot, using the #PIN_SELECT syntax which unlocks once and does all the specified mappings.
Look at the sticky at the top of the forum for this. |
Thanks for the answers, but I feel more stupid after reading them ( I know I am not getting it because my stupidity, sorry for the work).
1>after looking to table 1 page 5 ( I didn’t realize its existence before) is clear to me that pins RA0 and RA1 are ICSPDAT and ICSPCLK as soon as chip is powered, so that solves one of my problems.
2> still in doubt if using #use rs232(baud=9600,parity=N,xmit= PIN_C4,rcv=PIN_C3,bits=8,stream=PORT1)
WILL the CCS compiler select pins C3 and C4 for the RS232, or an additional pin assignment is necessary.
3> THE DUMMY ($1) QUESTION
if I just select RS232 as the only necessary peripheral and considering that RA0/ RA1 / RA3 / RA4 and RA5 are already assigned by default, leaving all other pins without assignment:
Will the other pins be connected to normal I/O ports, or an additional definition is needed?????
CAN I EXPECT that PORT B and PORT C will by default assigned to corresponding pins (PORTB bidirectional pins will be physically located to pins RB4/5/6/7 for example, same with PORT C).
Hope I am being clear with the doubts.
Thanks a lot for the time expend by you and the others that answered.
juan |
|
![](templates/subSilver/images/spacer.gif) |
Ttelmah
Joined: 11 Mar 2010 Posts: 19369
|
|
Posted: Sun Aug 06, 2017 1:23 pm |
|
|
Look at the sticky at the top of the forum.
This shows how to setup your UART.
No, just using the pins will result in a software UART being generated.
There is no assignment associated with being a normal I/O pin. The pin 'is' PIN_A0, PIN_A1 etc.. It is the peripherals that then have to be attached to the pins.
However a caveat to this. You need to look at the pin priority in the data sheet. Some things wake up by default enabled to 'take over' the assignments. Typical things like an ECCP PWM, will have some pins assigned to them at boot. This is done because these are designed to drive particular peripherals where you want the pin driven on boot. So on pins involving devices like this you have to explicitly disable the peripheral before they become available for normal use. |
|
![](templates/subSilver/images/spacer.gif) |
jujoab
Joined: 05 Aug 2017 Posts: 41 Location: brazil
|
|
Posted: Sun Aug 06, 2017 7:38 pm |
|
|
Ttelmah wrote: | Look at the sticky at the top of the forum.
This shows how to setup your UART.
No, just using the pins will result in a software UART being generated.
There is no assignment associated with being a normal I/O pin. The pin 'is' PIN_A0, PIN_A1 etc.. It is the peripherals that then have to be attached to the pins.
However a caveat to this. You need to look at the pin priority in the data sheet. Some things wake up by default enabled to 'take over' the assignments. Typical things like an ECCP PWM, will have some pins assigned to them at boot. This is done because these are designed to drive particular peripherals where you want the pin driven on boot. So on pins involving devices like this you have to explicitly disable the peripheral before they become available for normal use. |
My appreciation to all, doubts were clarified by your notes.
As a result I discovered that compiling from Proteus for the combination of Proteus 8.6 and actual ccs compiler do not accept at the chip selection the ccs compiler for that specific chip.
I am now editing and compiling on the CCS console and having Proteus open so the new COF file is detected by Proteus and loading immediately.
So, when I move from ccs console to Proteus for the simulation, simulator is already loaded, ready to go.
"now the PPS work all right"
Thanks to all.
juan |
|
![](templates/subSilver/images/spacer.gif) |
Ttelmah
Joined: 11 Mar 2010 Posts: 19369
|
|
Posted: Mon Aug 07, 2017 12:07 am |
|
|
Worthwhile looking at the other sticky at the top of the Forum about the Proteus simulator...
Honestly you are much better off using a real chip, than the Proteus simulator.
It is a competent simulator for analog circuitry, but for the PIC's, on most chips there are faults with the simulator. It uses 'global' models of the peripherals, where on the real PIC's, many of the peripherals behave differently on different chips. It accepts 'what you tell it', about clocks, even when what it is being told is wrong. You can set up a complete project in Proteus, have it working, then move it to the real PIC, and have to start developing a second time to get it working on the chip. Once it is working, you can try it back in Proteus, and have this tell you that it won't work....
Time used testing/developing PIC code in Proteus, is in many cases wasted. ![Sad](images/smiles/icon_sad.gif) |
|
![](templates/subSilver/images/spacer.gif) |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|