Page 1 of 1

PIC18F24J50 oscillator setting do not work

Posted: Fri Mar 19, 2021 1:12 pm
by SpeedPIC32
Hi,
I need help
I want to run it with the 8Mhz internal and USB
no matter what I set, it flashes every 2 seconds
I'm curious what I'm doing wrong :roll: :roll:

thank you and have a nice weekend

Re: PIC18F24J50 oscillator setting do not work

Posted: Fri Mar 19, 2021 3:43 pm
by p.erasmus
Hi,

I do not have such a device to test however these settings should run your PIC at 48MHz for USB FS with the Internal OSC

PIC18F24J50.rar
(2.5 KiB) Downloaded 698 times

Re: PIC18F24J50 oscillator setting do not work

Posted: Fri Mar 19, 2021 4:08 pm
by chipfryer27
Hi SpeedPIC32

In your settings you have the chip set to look for an external clock on Port A7 (ECPLL), perhaps set that to INTOSC, and you will probably need a C-code block at the beginning containing OSCCON=0x70;

I don't have that chip to try out myself.

Hope this helps.

Regards

Edit

Haha
I've just pretty much said what Qmesar did <s>

Re: PIC18F24J50 oscillator setting do not work

Posted: Fri Mar 19, 2021 5:19 pm
by SpeedPIC32
first of all thank you chipfryer27
unfortunately the chip does not want to run at 48 MHz yet.
it runs at 8 MHz???
do you have another idea?
does it have to do with saving power?

Regards

[color=#FF0000] Re: PIC18F24J50 oscillator setting do not work[/color]

Posted: Fri Mar 19, 2021 6:24 pm
by SpeedPIC32
The problem seems to be bigger. :twisted:
I set OSCTUNE = 0xc0 with the same settings and additionally.
FC9 does not respond to this.
With the software mikroBasic Pro for PIC I got the PIC to run at 48Mhz.
I also have there too
OSCCON = 0x70 and OSCTUNE = 0xc0 set.

configuration register
CONFIG1L : $3FF8 : 0x008E
CONFIG1H : $3FF9 : 0x00F7
CONFIG2L : $3FFA : 0x0012
CONFIG2H : $3FFB : 0x00FF
CONFIG3L : $3FFC : 0x00F7
CONFIG3H : $3FFD : 0x00F9
CONFIG4L : $3FFE : 0x00CF
CONFIG4H : $3FFF : 0x00F1

program pic18f24j50

' Declarations section

' Main program
dim uart_rd as byte

main:

OSCCON = 0x70
OSCTUNE = 0xc0

trisc.2=0
portc.2=0
UART1_Init(9600) ' Initialize UART module at 9600 bps
Delay_ms(100) ' Wait for UART module to stabilize

UART1_Write_Text("Ready")
UART1_Write(10) ' Line Feed
UART1_Write(13) ' Carriage Return

while (TRUE) ' Endless loop
if (UART1_Data_Ready() <> 0) then ' If data is received,
uart_rd = UART1_Read() ' read the received data,
UART1_Write(uart_rd) ' and send data via UART
end if
portc.2=1
delay_ms(1000)
portc.2=0
delay_ms(1000)
wend
end.

Re: PIC18F24J50 oscillator setting do not work

Posted: Fri Mar 19, 2021 7:47 pm
by chipfryer27
Hi

I'll have a look and hopefully will get back to you over the weekend. Unfortunately I don't have that chip to try things with myself so (if) anything I do come back with would be based on datasheet info. It does sound like a setting isn't quite right though.

Did Qmesar's code not run at all?

Regards

Re: PIC18F24J50 oscillator setting do not work

Posted: Sat Mar 20, 2021 12:02 am
by SpeedPIC32
The program was executed but only at 8 MHz
With the same setting, the same program runs under MicroBasik at 48Mhz.
I did everything the same way.
I also tested the built-in compiler and the latest XC8 compiler. without success. it seems that the PLL is not switched on

best regards

Re: PIC18F24J50 oscillator setting do not work

Posted: Sat Mar 20, 2021 12:07 am
by SpeedPIC32
here is my program

Thank you for your help

Re: PIC18F24J50 oscillator setting do not work

Posted: Sun Mar 21, 2021 12:08 pm
by SpeedPIC32
hi chipfryer27
After restarting the computer, the chip runs at 48Mhz

It was due to the OSCCON register and also the OSCTUNE register

Thank you for your help