ilker07
Joined: 03 Jun 2022 Posts: 40
|
SOSCO and SOSCI pins as output |
Posted: Tue Feb 04, 2025 12:21 am |
|
|
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
|
|
Posted: Tue Feb 04, 2025 4:38 am |
|
|
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. |
|