View previous topic :: View next topic |
Author |
Message |
ELINAP
Joined: 05 Sep 2013 Posts: 14
|
Disable secondary oscillator in PIC24F16KA101 |
Posted: Thu Sep 05, 2013 2:25 am |
|
|
Hi,
I use a PIC24F16KA101 and i want to use the secondary oscillator pins for general purpose IO, but this doesn't work SOSCEN bit =0. If someone have an idea ?
Does the compile directive "#DELAY()" impact the secondary oscillator??
Any assistance would be greatly appreciated.
Best regards |
|
|
jeremiah
Joined: 20 Jul 2010 Posts: 1349
|
|
Posted: Thu Sep 05, 2013 4:05 pm |
|
|
I don't have that specific chip, but for the PIC24F32KA302 a fuse must be set before you can use them as digital I/O. Check your fuses for the chip as a starting point. |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19515
|
|
Posted: Fri Sep 06, 2013 12:17 am |
|
|
Post:
1) Compiler version.
2) Fuses.
3) #use delay line
4) Any 'setup_oscillator' statement(s).
5) Setup used on timer1.
Last is the most likely problem. You need to ensure timer1 is set to use 'internal', or _it_ uses the secondary oscillator.
Best Wishes |
|
|
ELINAP
Joined: 05 Sep 2013 Posts: 14
|
|
Posted: Fri Sep 06, 2013 1:39 am |
|
|
Hi,
Thanks for theses answers.
For more infos:
Compiler CCS IDE V5.001
Fuses:
Code: |
#FUSES NOWDT //No Watch Dog Timer
#FUSES NOWRTB //Boot block not write protected
#FUSES NOBSS //No boot segment
#FUSES NOPROTECT //Code not protected from reading
#FUSES NOWRT //Program memory not write protected
#FUSES NODEBUG //No Debug mode for ICD
#FUSES NOWINDIS //Watch Dog Timer in non-Window mode
#FUSES NOBROWNOUT //No brownout reset
#FUSES MCLR //Master Clear pin enabled
#FUSES NODSBOR
#FUSES NOIESO //Internal External Switch Over mode enabled
#FUSES OSCIO //OSC2 is general purpose output
#FUSES NOCKSFSM //Clock Switching is disabled, fail Safe clock monitor is disabled
#FUSES NOPUT //Power Up Timer
#FUSES ICSP2 //ICD uses PGC1/PGD1 pins
#FUSES NODSWDT
#FUSES NOPR
#FUSES FRC //Internal oscillator FRC
#use delay(internal=8MHZ)
|
Init:
Code: |
OSCCON=0x0010;
setup_rtc(RTC_DISABLE);
setup_timer1(TMR_DISABLED); // don't use it
setup_timer2(TMR_INTERNAL |TMR_DIV_BY_256 ,1420);
setup_timer3(TMR_DISABLED |TMR_DIV_BY_1 ,0);
set_pullup(TRUE,PIN_A4);
SOSCEN=0;
OSWEN=0;
setup_ADC_PORTS(sAN0,VSS_VDD);
setup_adc(ADC_CLOCK_INTERNAL | ADC_TAD_MUL_4);
set_adc_channel(0);
|
I don't use the "setup_oscillator" instruction because I need OSCI and OSCO pins as general purpose IO ( this is OK ) but I want the same thing with the pins SOSCI and SOSCO.
Best regards |
|
|
FvM
Joined: 27 Aug 2008 Posts: 2337 Location: Germany
|
|
Posted: Sat Sep 07, 2013 5:11 am |
|
|
I don't understand the problem.
24F16KA101 secondary oscillator is diabled by default, there's nothing you have to do about it to use the
respective pins as general IO. |
|
|
ELINAP
Joined: 05 Sep 2013 Posts: 14
|
|
Posted: Mon Sep 09, 2013 5:53 am |
|
|
I don't understand too.
Thanks even so. |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19515
|
|
Posted: Mon Sep 09, 2013 7:47 am |
|
|
I'd be suspicious of 5.001.
It was the first 'beta' release of V5. Might not be actually setting fuses correctly. Try loading the generated file into MPLAB, and verify what the actual fuse selections are.
Best Wishes |
|
|
ELINAP
Joined: 05 Sep 2013 Posts: 14
|
Solved |
Posted: Thu Sep 12, 2013 3:39 am |
|
|
Hi,
Thanks for the idea to use MPLAB. I found the problem.
"FUSES RTCOSC_LP" was missing. The RTCC still use the secondary oscillator.
Best regards |
|
|
|