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

SOSCO and SOSCI pins as output

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



Joined: 03 Jun 2022
Posts: 40

View user's profile Send private message

SOSCO and SOSCI pins as output
PostPosted: Tue Feb 04, 2025 12:21 am     Reply with quote

Hi,everyone I wanna use SOSCO and SOSCI(C0 and C1) pins as output but I couldn't.I used some fuses like SOSC_DIG but it didn't work.

#include <18LF26K22.h>


//#use delay(internal=8MHz) //==> it works with delay_ms
#use delay(internal=16MHz) //it does not work with delay_ms
//#use delay(internal=16MHz,clock=64MHz)//it does not work with delay_ms
#use fast_io(c)


#FUSES NOWDT
#FUSES WDT128
#FUSES NOXINST
#FUSES NOBROWNOUT
#FUSES PROTECT
#FUSES NOMCLR
//#FUSES SOSC_DIG


with these fuses I can' t use 16 mhz clock and delay_ms functions.Please help.
Ttelmah



Joined: 11 Mar 2010
Posts: 19649

View user's profile Send private message

PostPosted: Tue Feb 04, 2025 4:38 am     Reply with quote

Start with the oscillator setup.
The correct setting to use the internal oscillator with the PLL at 64MHz, is
simply:

#use_delay(internal=64MHz)

The compiler knows that the PLL has to be used to get the 64MHz rate, and
enables it.
Your 64Mhz line you had, would give delays 4* wrong, since you are setting up
the oscillator to give 16MHz, and then telling the compiler you are
running at 64MHz.

On your chip, the secondary oscillator is not a fuse controlled device,
unless you choose it as the system clock.
The pins are available for digital I/O, unless you setup the secondary
oscillator, hence no fuses. This is setup by either selecting it
as the master clock, or with the timers.

Remember that since you are setting FAST_IO(c), you will have to
manually set the TRIS or the pins will not work.

So a basic test:
Code:

#include <18LF26K22.h>

#use delay(internal=64MHz)
#use fast_io(c)

#FUSES NOWDT
#FUSES WDT128
#FUSES NOXINST
#FUSES BROWNOUT //Code will generally always be more reliable if
//you enable this. Set a voltage that suits your supply.
#FUSES BORV19
#FUSES PUT //again this helps to solve startup issues.
#FUSES NOPROTECT //Read on this. Do not turn on protection
//when testing code. Doing so wastes lives of the chip.
#FUSES NOMCLR

void main(void)
{
    set_tris_c(0); //setup C as output

    while (TRUE)
    {
         output_toggle(PIN_C0);
         output_toggle(PIN_C1);
         delay_ms(500);
    }
}


Merrily gives C0 and C1 at 1Hz.
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