CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

Problem use the pins of the SOSC as IO (24FJ128GA308)

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Steve_P



Joined: 05 Jun 2017
Posts: 6

View user's profile Send private message

Problem use the pins of the SOSC as IO (24FJ128GA308)
PostPosted: Mon Jun 05, 2017 4:28 am     Reply with quote

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

View user's profile Send private message

PostPosted: Mon Jun 05, 2017 4:49 am     Reply with quote

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. Smile

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. Smile
Steve_P



Joined: 05 Jun 2017
Posts: 6

View user's profile Send private message

PostPosted: Mon Jun 05, 2017 5:07 am     Reply with quote

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

View user's profile Send private message

PostPosted: Mon Jun 05, 2017 5:23 am     Reply with quote

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

View user's profile Send private message

PostPosted: Mon Jun 05, 2017 6:01 am     Reply with quote

Ok, thank you for help.
It's my fault: C13 and C14 are not IO, they are only Input-Pin.... Idea

F..... , now I have to change the HW Shocked
Ttelmah



Joined: 11 Mar 2010
Posts: 19520

View user's profile Send private message

PostPosted: Mon Jun 05, 2017 6:25 am     Reply with quote

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.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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