View previous topic :: View next topic |
Author |
Message |
Steve_P
Joined: 05 Jun 2017 Posts: 6
|
Problem use the pins of the SOSC as IO (24FJ128GA308) |
Posted: Mon Jun 05, 2017 4:28 am |
|
|
Hello
I need to use the SOSC Pins (PIN_C13, PIN_C14) as IO.
I try a lot but it does not work.
For test I use the simple Example blinking LED program
PIN_C12 and C15 toggle, PIN_C13 and C14 don't
c file:
Code: |
#include <main.h>
#word OSCCON =getenv("SFR:OSCCON")
void main()
{
bit_clear(OSCCON,1);
setup_timer1(TMR_INTERNAL);
setup_rtc(RTC_DISABLE | RTC_CLOCK_INT);
set_tris_c(0x0000);
//Example blinking LED program
while(true)
{
output_low(PIN_C12);
output_low(PIN_C13);
output_low(PIN_C14);
output_low(PIN_C15);
delay_ms(1000);
output_high(PIN_C12);
output_high(PIN_C13);
output_high(PIN_C14);
output_high(PIN_C15);
delay_ms(1000);
}
} |
h file:
Code: |
#include <24FJ128GA308.h>
#FUSES NOWDT //No Watch Dog Timer
#FUSES NOJTAG //JTAG disabled
#FUSES CKSFSM //Clock Switching is enabled, fail Safe clock monitor is enabled
#FUSES NOBROWNOUT //No brownout reset
#FUSES OSCIO //OSC2 is general purpose output
#FUSES NOCKSNOFSM
#FUSES NOIESO
#FUSES NOVBATBOR
#FUSES SOSC_DIG //Digital mode, I/O port functionality of SOSCI and SOSCO pins
#FUSES NOBROWNOUT //No brownout reset
#FUSES DSWDTCK_LPRC //DSWDT uses LPRC as reference clock
#device ICSP=1
#use delay(internal=32MHz) |
Compiler is V5073
Thank you for help.... |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19520
|
|
Posted: Mon Jun 05, 2017 4:49 am |
|
|
This has been covered only a couple of days ago....
Just do this:
Code: |
#include <24FJ128GA308.h>
#device ICSP=1
#use delay(internal=32MHz)
#FUSES NOWDT //No Watch Dog Timer
#FUSES NOJTAG //JTAG disabled
#FUSES CKSFSM //Clock Switching is enabled, fail Safe clock monitor is enabled
#FUSES NOBROWNOUT //No brownout reset
#FUSES OSCIO //OSC2 is general purpose output
#FUSES NOCKSNOFSM
#FUSES NOIESO
#FUSES NOVBATBOR
#FUSES SOSC_DIG //Digital mode, I/O port functionality of SOSCI and SOSCO pins
#FUSES NOBROWNOUT //No brownout reset
#FUSES DSWDTCK_LPRC //DSWDT uses LPRC as reference clock
|
Order is everything.
The default 'internal=xxx' setting, overrides the OSCIO fuse.
If you put this _in front_ of the fuse selections, the fuse takes priority over this.
I knew it overrode the oscillator selection, but hadn't 'twigged' it overrode the OSCIO fuse. Another poster worked this out. |
|
|
Steve_P
Joined: 05 Jun 2017 Posts: 6
|
|
Posted: Mon Jun 05, 2017 5:07 am |
|
|
Hi, thank you for your fast answer.
I copied this to my h file, but it is the same.
The OSC Pins ( C12/C15 ) are toggle.
The SOSC Pins ( C13/C14 ) don't.
This means the OSCIO fuse seems to work.
The SOSC_DIG fuse dont work.
Any more Ideas??? |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19520
|
|
Posted: Mon Jun 05, 2017 5:23 am |
|
|
Apologies. I thought you were having problems with the primary oscillator pins. On some compiler versions these won't work as I/O, unless the setup is as I show.
On the secondary, the standard answer applies. There are several peripherals that also use these pins, and you have to ensure they are all disabled. The timer you should already have, but comparator 3 is also here, and the comparators have a habit of stopping pins from being used for normal I/O. |
|
|
Steve_P
Joined: 05 Jun 2017 Posts: 6
|
|
Posted: Mon Jun 05, 2017 6:01 am |
|
|
Ok, thank you for help.
It's my fault: C13 and C14 are not IO, they are only Input-Pin....
F..... , now I have to change the HW |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19520
|
|
Posted: Mon Jun 05, 2017 6:25 am |
|
|
Know that feeling....
That's where I like to sit down now with a written table of everything I want to put on the pins and then re-read the data sheet three times for each pin. |
|
|
|