INTOSC problem

27 views
Skip to first unread message

vsurducan

unread,
Feb 13, 2021, 3:28:41 AM2/13/21
to jal...@googlegroups.com
Hi all,
Perhaps you can see where the problem is below, the 18F25K50 doesn't want to run with an internal oscillator and PLL. Thanks!

include 18f25k50                     -- target PICmicro
--
-- This program assumes that no resonator or crystal
-- is connected to pins OSC1 and OSC2.
pragma target clock 48_000_000      -- oscillator frequency
--
pragma target OSC      INTOSC_NOCLKOUT           -- internal oscillator
pragma target PLLSEL   PLL3X                     -- 3x16MHz = 48MHz
pragma target PLLEN    ENABLED                   -- PLL on
pragma target CPUDIV   P1                        -- CPU uses system clock 48MHz
pragma target LS48MHz  P8                        -- USB 48MHz/8 = 6MHz
pragma target WDT      DISABLED                  -- watchdog
pragma target XINST    DISABLED                  -- do not use extended instruction set
pragma target DEBUG    DISABLED                  -- no debugging
pragma target BROWNOUT DISABLED                  -- no brownout reset
pragma target FCMEN    DISABLED                  -- no clock monitoring
pragma target IESO     DISABLED                  -- no int/ext osc switching
pragma target LVP      ENABLED                   -- low voltage programming
pragma target MCLR     EXTERNAL                  -- external reset
--
-- The configuration bit settings above are only a selection, sufficient
-- for this program. Other programs may need more or different settings.
--
OSCCON_IRCF = 0b111                 -- select INTOSC to 16MHz
OSCCON_SCS = 0b00                   -- select primary clock defined by CONFIG1H <FOSC3:0>
OSCCON2_PLLEN = TRUE                -- use PLL
--
enable_digital_io()                 -- make all pins digital I/O
--
-- A low current (2 mA) led with 2.2K series resistor is recommended
-- since the chosen pin may not be able to drive an ordinary 20mA led.
--
alias  led       is pin_A0          -- alias for pin with LED
--
pin_A0_direction = OUTPUT
--
forever loop
   led = ON
   _usec_delay(100_000)
   led = OFF
   _usec_delay(400_000)
end loop
--

vsurducan

unread,
Feb 13, 2021, 4:38:39 AM2/13/21
to jal...@googlegroups.com
Ok, solved the issue, perhaps this should be written in the blink files:
On PIC18F25K50 (and probably others) if you keep the programmer connected on the ICSP and the LVP is ENABLED,
the LED connected on pinA0 will not blink until you disconnect the programmer from the ICSP port.
The reason why this happen  is described in the datasheet: "While in Low-Voltage ICSP™ mode,
MCLR is always enabled, regardless of the MCLRE bit"
meaning that with the programmer connected permanently to the microcontroller, the microcontroller will be continuously in reset,
the effect will be no blink of the LED and the wrong conclusion can be that the oscillator was not configured correctly.
thank you

Rob CJ

unread,
Feb 13, 2021, 8:23:08 AM2/13/21
to jal...@googlegroups.com
Hi Vsurducan,

I did a test on a PIC18F25k50 using the following sample program and it worked without problems. I did not need to disconnect my Pickit3 to have a blinkind LED. So not sure which problem you are having.

-----

include 18f25k50                     -- target PICmicro
--
-- This program uses the internal oscillator at 4 MHz.
pragma target clock    4_000_000       -- oscillator frequency
--
pragma target OSC      INTOSC_NOCLKOUT           -- internal oscillator
pragma target PLLEN    DISABLED                  -- PLL off
pragma target CPUDIV   P1                        -- Fosc divisor
pragma target WDT      DISABLED                  -- watchdog
pragma target XINST    DISABLED                  -- do not use extended instructionset
pragma target DEBUG    DISABLED                  -- no debugging
pragma target BROWNOUT DISABLED                  -- no brownout reset
pragma target FCMEN    DISABLED                  -- no clock monitoring
pragma target IESO     DISABLED                  -- no int/ext osc switching
pragma target LVP      ENABLED                   -- low voltage programming
pragma target MCLR     EXTERNAL                  -- external reset
--
-- The configuration bit settings above are only a selection, sufficient
-- for this program. Other programs may need more or different settings.
--
OSCCON_SCS = 0                      -- select primary oscillator
OSCCON_IRCF = 0b101                 -- 4 MHz
--
enable_digital_io()                 -- make all pins digital I/O
--
-- A low current (2 mA) led with 2.2K series resistor is recommended
-- since the chosen pin may not be able to drive an ordinary 20mA led.
--
alias  led       is pin_A0          -- alias for pin with LED
--
pin_A0_direction = OUTPUT
--
forever loop
   led = ON
   _usec_delay(100_000)
   led = OFF
   _usec_delay(400_000)
end loop

-----

Kind regards,

Rob


Van: jal...@googlegroups.com <jal...@googlegroups.com> namens vsurducan <vsur...@gmail.com>
Verzonden: zaterdag 13 februari 2021 10:38
Aan: jal...@googlegroups.com <jal...@googlegroups.com>
Onderwerp: [jallib] Re: INTOSC problem
 
--
You received this message because you are subscribed to the Google Groups "jallib" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jallib+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jallib/CAM%2Bj4qv4wTqPAdxVCz94kX_w9Se_fMUhtHuJ4hNZjqbmn8MuSA%40mail.gmail.com.

vsurducan

unread,
Feb 14, 2021, 1:11:50 AM2/14/21
to jal...@googlegroups.com
I solved, thank you. My PICkit didn't change the MCLR line to HZ after programming but kept it low.
It's the first time I saw this behaviour after a million programming cycles or so...:) 


Reply all
Reply to author
Forward
0 new messages