|
|
View previous topic :: View next topic |
Author |
Message |
apakSeO
Joined: 07 Dec 2016 Posts: 60 Location: Northeast USA
|
Cannot set pin function using #pin_select |
Posted: Wed Dec 07, 2016 8:42 am |
|
|
The CCS Compiler manual states:
Quote: | #PIN_SELECT function=pin_xx |
Quote: | function is the Microchip defined pin function name, such
as: U1RX (UART1 receive), INT1 (external interrupt 1),
T2CK (timer 2 clock), IC1 (input capture 1), OC1 (output
capture 1). |
However, where are these 'function' names defined? Under the #pin_select section the CCS Manual lists, for example, 'P1A', 'P2B', 'TX2' as functions but I cannot find P1A, P2B anywhere on a Microchip datasheet as a valid pin function. And of course the valid pin functions listed in the manual seem like a very small subset of all available functions that various pins are able to take on ...
Another explicit example: Datasheet for PIC18F46J50 family, page 5:
http://ww1.microchip.com/downloads/en/DeviceDoc/39931b.pdf
I want to output the reference clock ( using 44-pin TQFP ) on pin RB2. The mulitplexed pin function diagram on page 5 says:
RB2/AN8/CTEDG1/PMA3/VMO/REFO/RP5
So intuitively I think I should write code like this:
Code: | #pin_select REFO=PIN_B2 |
because I want to select pin 10 as the REFO function. "REFO" seems to be the Microchip-defined pin function name, isn't it? However, CCS will not compile and returns an error: Invalid pre-processor directive Invalid Pin ID
So what's the story here? Do I have to write directly to the uC's register address for REFOCON in order to enable REFO output on port B2? What am I missing here?
[/code] |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19518
|
|
Posted: Wed Dec 07, 2016 9:19 am |
|
|
If you look in the header file for your chip, it gives the function names and what pins can be used.
The reason you can't relocate the reference clock output, is it is not a relocatable peripheral. It has a fixed output pin RB2.
If you look in the data sheet, the input peripherals that can be relocated are shown in table 9-13, and the output peripherals in table 9-14. The function names in these tables are the function names used by CCS.
In Table 9-14, for example, Microchip have:
Code: |
CCP1/P1A 14 ECCP1 Compare or PWM Output Channel A
P1B 15 ECCP1 Enhanced PWM Output, Channel B
|
The first is a 'combined' function CCP1 or P1A. These are the names used by CCS, the second is the P1B function. |
|
|
apakSeO
Joined: 07 Dec 2016 Posts: 60 Location: Northeast USA
|
|
Posted: Wed Dec 07, 2016 9:32 am |
|
|
Ttelmah wrote: | If you look in the header file for your chip, it gives the function names and what pins can be used.
The reason you can't relocate the reference clock output, is it is not a relocatable peripheral. It has a fixed output pin RB2.
If you look in the data sheet, the input peripherals that can be relocated are shown in table 9-13, and the output peripherals in table 9-14. The function names in these tables are the function names used by CCS.
In Table 9-14, for example, Microchip have:
Code: |
CCP1/P1A 14 ECCP1 Compare or PWM Output Channel A
P1B 15 ECCP1 Enhanced PWM Output, Channel B
|
The first is a 'combined' function CCP1 or P1A. These are the names used by CCS, the second is the P1B function. |
Ah yes, OK. The PPS Module is controlled by the #pin_select directives. I understand, thank you for elucidating this point to me.
But a question still stands: How do I make active the REFO function of pin 10 then, using the CCS compiler? Using the xc8 compiler, I simply am able to directly set REFOCON |= 0x80. In CCS, I cannot find any reference to "REFO", "REFOCON".
More generally: on pins that are not mappable through the PPS module, how does one select the different pin functions if I cannot find a reference to the function in the CCS User Guide/Manual? |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Wed Dec 07, 2016 9:52 am |
|
|
Quote: |
How do I make active the REFO function of pin 10 then, using the CCS compiler?
Using the xc8 compiler, I simply am able to directly set REFOCON |=0x80.
In CCS, I cannot find any reference to "REFO", "REFOCON". |
See my reply in this thread:
http://www.ccsinfo.com/forum/viewtopic.php?t=52602
You can tell the compiler (if you have the IDE version) to make an include
file with all the register definitions in it. #include that file near the top
of your program and yhen you will have REFOCON available.
Quote: | On pins that are not mappable through the PPS module, how does one select the different pin functions if I cannot find a reference to the function in the CCS User Guide/Manual? |
Generally CCS will have a function to enable the module. If they don't
then you have to do it manually in code, as you referenced above. |
|
|
apakSeO
Joined: 07 Dec 2016 Posts: 60 Location: Northeast USA
|
|
Posted: Wed Dec 07, 2016 9:59 am |
|
|
PCM programmer wrote: | Quote: |
How do I make active the REFO function of pin 10 then, using the CCS compiler?
Using the xc8 compiler, I simply am able to directly set REFOCON |=0x80.
In CCS, I cannot find any reference to "REFO", "REFOCON". |
See my reply in this thread:
http://www.ccsinfo.com/forum/viewtopic.php?t=52602
You can tell the compiler (if you have the IDE version) to make an include
file with all the register definitions in it. #include that file near the top
of your program and yhen you will have REFOCON available.
Quote: | On pins that are not mappable through the PPS module, how does one select the different pin functions if I cannot find a reference to the function in the CCS User Guide/Manual? |
Generally CCS will have a function to enable the module. If they don't
then you have to do it manually in code, as you referenced above. |
Thank you.
I'm using MPLAB X as my IDE ( just used to this IDE )
Is the header file from CCS's IDE portable to other IDE's? If I install the CCS IDE, create that include header file as you mention above, and then add it to my MPLAB project / includes, do you know if the header with register definitions should be readable and compile correctly within MPLAB? |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Wed Dec 07, 2016 10:21 am |
|
|
It's just an include file. The IDE doesn't matter. It's the compiler that
uses it. It will work. |
|
|
apakSeO
Joined: 07 Dec 2016 Posts: 60 Location: Northeast USA
|
|
Posted: Wed Dec 07, 2016 10:57 am |
|
|
PCM programmer wrote: | It's just an include file. The IDE doesn't matter. It's the compiler that
uses it. It will work. |
More weirdness and confusion:
I've been able to manually map the byte/bit registers I want ( everything REFOCON ) in the following manner:
Code: |
#BYTE REFOCON = getenv("SFR:REFOCON")
#BIT RODIV0 = REFOCON.0
#BIT RODIV1 = REFOCON.1
#BIT RODIV2 = REFOCON.2
#BIT RODIV3 = REFOCON.3
#BIT ROSEL = REFOCON.4
#BIT ROSSLP = REFOCON.5
// Skip bit 6 because it is not mapped to anything
#BIT ROON = REFOCON.7
|
This code works fine, and I can directly modify ROON, RODIV0, etc. with no problems.
However, I want to replicate this with the CCS C Compiler processor-specific header file method mentioned by you above. Start->PIC-C->PIC C Compiler; Tools->Device Table Editor -> Select my part ( PIC18F46J50 ), hit the Registers tab. OK great, I see registers listed, specifically, REFOCON which I am interested in. The register name itself is correct, its address is also correct ( 0xF3D ) ... but all the bit field names are completely wrong:
REFOCON does not have any bits named RTSECSEL1, PMPTT, ADCAL, WDTW .... this is all completely wrong. Consequently, the generated header file is completely wrong and unusable with the bitfield names specified in the datasheet. It appears as thought some of the correct bit field names appear 3 rows down ( ROSEL, RODIVx ... ) but again they are out of place and bit7 should be "ROON"
Am I missing something here? Or have I stumbled upon a bug with this specific PIC18 part in the CCS compiler? |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Wed Dec 07, 2016 11:22 am |
|
|
It's not right, but what's your CCS compiler version ?
Here is a list of ways to find the CCS compiler version:
1. Compile a test file, and look at the top of the .LST file, which will
be in your project folder. It will show the version. However, to get
the .LST file to be generated, the source file must compile with no errors.
2. Click on the Start button in Windows, then go to Programs, and then
find the entry for CCS, which will be called "PIC-C". Then click on the icon
for "Compiler Version". It will display a box which shows the compiler
version.
3. Open a Command Prompt window and go to c:\Program Files\Picc
(or wherever the compiler is installed on your PC) and run this command line: Quote:
CCSC.exe +v |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19518
|
|
Posted: Wed Dec 07, 2016 12:08 pm |
|
|
He must have a very low V5 version.
The first dozen or so V5 releases, were 'beta'. My guess is he has 5.008, which is a commonly 'ripped off' version on the web.
By 5.014, it was fixed. |
|
|
apakSeO
Joined: 07 Dec 2016 Posts: 60 Location: Northeast USA
|
|
Posted: Wed Dec 07, 2016 12:27 pm |
|
|
Ttelmah wrote: | He must have a very low V5 version.
The first dozen or so V5 releases, were 'beta'. My guess is he has 5.008, which is a commonly 'ripped off' version on the web.
By 5.014, it was fixed. |
I'm using this compiler from my university's archive repository; The version reported is 5.009. I am going to attempt to find an updated version of CCS but chances are slim.
Nevertheless, thank you everybody for your help on this thread! |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19518
|
|
Posted: Thu Dec 08, 2016 1:55 am |
|
|
Sorry I sounded a bit 'negative'.
We suffer from a very large number of people with the 5.008 copy, having annoying problems....
If your university bought the compiler at this time, then 'talk to CCS'. They might well do you a student version, or just update the chip database. Point out the problem, and talk nicely. They are generally very good about this. |
|
|
|
|
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
|