PIC18F26J50 Oscilator Problem 48Mhz

Any bugs you encounter with Flowcode should be discussed here.
Post Reply
SpeedPIC32
Posts: 252
http://meble-kuchenne.info.pl
Joined: Thu Dec 10, 2020 2:35 pm
Has thanked: 36 times
Been thanked: 17 times

PIC18F26J50 Oscilator Problem 48Mhz

Post by SpeedPIC32 »

hello

I have an oscillator problem with the PIC18F26J50 I can't get the 48Mhz.
12Mhz crystal divider by 3 with PLL is running way too slow. 1Sek clock is not possible.

I need a good tip
Formaldehyd Tester 3.fcfx
(32.79 KiB) Downloaded 36 times

BenR
Matrix Staff
Posts: 1745
Joined: Mon Dec 07, 2020 10:06 am
Has thanked: 444 times
Been thanked: 604 times

Re: PIC18F26J50 Oscilator Problem 48Mhz

Post by BenR »

Hello,

Your settings look largely correct to me, One thing to try is enabling the "Internal External Oscillator Switch Over Mode" setting in config word 0x02.

Also in project options under Other Options you have Auto Clear watchdog set but the watchdog is diabled in the chip config, this shouldn't really effect things too much but if you're not using the watchdog then it makes sense to disable this feature, saves you a bit of ROM/Runtime hit.

SpeedPIC32
Posts: 252
Joined: Thu Dec 10, 2020 2:35 pm
Has thanked: 36 times
Been thanked: 17 times

Re: PIC18F26J50 Oscilator Problem 48Mhz

Post by SpeedPIC32 »

Hello Ben

I have to set a delay of 960msek to get to one second on and off.
the PIC18F24-26J50 all do this in the same way.
a delay of one second is too long.
If I program a delay of 960msek then I get to one second.


please check once
loop.pdf
(26.4 KiB) Downloaded 45 times

BenR
Matrix Staff
Posts: 1745
Joined: Mon Dec 07, 2020 10:06 am
Has thanked: 444 times
Been thanked: 604 times

Re: PIC18F26J50 Oscilator Problem 48Mhz

Post by BenR »

Hello,

If you need bang on accurate timing you would be better off using a timer interrupt as this will accurately count instruction cycles. The timer interval component may help here.

For the software based delays used in the delay icons they are usually designed to produce a delay that is >= the delay requested.

This is the delay second code, you can see each loop and subroutine call will add a little overhead. It's done like this because the compiler has a maximum amount of delay it can produce in one go.

Code: Select all

void delay_ms(MX_UINT8 del)
{
	while (del--)
	{
		__delay_ms(1);
	}
}

void delay_s(MX_UINT8 del)
{
	MX_UINT8 i;
	for(i=0; i<del; i++)
	{
		delay_ms(250);
		delay_ms(250);
		delay_ms(250);
		delay_ms(250);
	}
}
If you like I can have another pass over the delay code and see if I can improve the timings a bit, it's been a while since I last went through this code.

Things that could be further effecting the software delay...
1. Do you have auto clear watchdog timer switched on in the project options?
2. Do you have any interrupts active?

SpeedPIC32
Posts: 252
Joined: Thu Dec 10, 2020 2:35 pm
Has thanked: 36 times
Been thanked: 17 times

Flowcode v10 Re: PIC18F26J50 Oscilator Problem 48Mhz

Post by SpeedPIC32 »

Hi Ben,


Things that might affect the software delay further....
1. have you set the watchdog timer to auto clear in the project options?
I have turned it off.
2. do you have any interrupts active?
I don't use them.

this is the first time i noticed that the delay has only about 1 sec.
is this not so noticeable with the PIC32?
I need exactly 10 minutes.

I will program an interrupt for that.

Thank you for this clarification.

Post Reply