View previous topic :: View next topic |
Author |
Message |
rovtech
Joined: 24 Sep 2006 Posts: 262
|
Some Port A I/O pins on PIC16F1509 do not work |
Posted: Mon Oct 03, 2016 9:17 am |
|
|
Where does one reference the meaning of #fuses INTRC_IO ?
Is this the only way to specify the internal oscillator and get the compiler to make RA4 and RA5 I/O?
If #fuses INTRC_IO is not used then RA4 and RA5 (maybe others) default to higher priority functions despite setting them to OUT using set_tris_a. Port A does not work using output_high (PIN_A4); because RA4 is actually CLKOUT according to TABLE 11-2: PORTA OUTPUT PRIORITY in the data sheet.
My program runs if #fuses HS and setup_oscillator (OSC_16MHZ); is used except RA4 and RA5 do not work as I/O because the compiler is expecting an XTAL on the pins.
The data sheet for the 16F1509 under Oscillator module is a bit misleading as it describes ECL, ECM, ECH, and EXTRC with the word External. One could imply that LP, XT, HS and INTOSC are all internal, but only INTOSC is internal. The 16F1509.h file has no INTOSC but has INTRC_IO which works. I assume the _IO means use IO.
Where do I look up the meaning of the many items in the .h files which do not appear in the data sheet, like INTRC_IO in the .h and INTOSC in the data sheet. Is guessing the only method?
Like any programming errors this one is now obvious but took some time to debug as there were no compile errors. |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19553
|
|
Posted: Mon Oct 03, 2016 9:37 am |
|
|
INTRC_IO is the correct fuse to use, but you need to add a line to configure timer1. This default to using these same pins.
setup_timer_1(T1_DISABLED);
The fuse relationship to Microchip names is described in fuses.txt. |
|
|
rovtech
Joined: 24 Sep 2006 Posts: 262
|
|
Posted: Mon Oct 03, 2016 12:20 pm |
|
|
Thanks Ttelmah, but where do I find fuses.txt. I searched my computer so it is not in a CCS folder. I looked at the CCS website under FAQ and Support.
Why do I need to disable Timer1? I have not done so and my program is OK. What if I need T1?
Why would the timer need these pins? I see that it can be clocked externally by SOSC0 and SOSC1 but would it not be internal by default? |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
|
rovtech
Joined: 24 Sep 2006 Posts: 262
|
|
Posted: Mon Oct 03, 2016 1:53 pm |
|
|
I would never have thought to look there!
It helps a bit and is a useful list to keep.
But why do I have to disable the timer? |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Mon Oct 03, 2016 6:35 pm |
|
|
Quote: | But why do I have to disable the timer? |
I don't think you have to. I was able to blink LEDs on pins A4 and A5
on a related PIC, the 16F1507, with the following program. This was
with compiler vs. 5.063. This was tested on a Microchip Low Pin Count board.
Code: |
#include <16F1507.h>
#fuses INTRC_IO,NOWDT
#use delay(clock=4M)
//==========================
void main()
{
output_low(PIN_A4);
output_high(PIN_A5);
while(TRUE)
{
output_toggle(PIN_A4);
output_toggle(PIN_A5);
delay_ms(500);
}
} |
|
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19553
|
|
Posted: Tue Oct 04, 2016 12:54 am |
|
|
It depends on his compiler version.
The secondary oscillator used by the timer is on the same pins. For some reason on some compilers it wakes with this selected. You don't have to disable it (set it to use the internal oscillator is OK), but the fact he was asking about not being able to use these pins, suggests he may have one of the compiler versions where this is enabled.
I met this when playing with these chips. It was fixed soon afterwards on the compiler. |
|
|
|