I am using SK40C.
I need to have a Microcontroller clock frequency of 48MHz when using 4 MHz crystal.
Device used is 18F4550. IDE used is MPLABX V5.05. Compiler used is XC8 V2.00.
Based on the datasheet, I added the following configuration settings in the code to achieve 48MHz cpu clock;
#pragma config PLLDIV = 1
#pragma config CPUDIV = OSC1_PLL2
#pragma config FOSC = XTPLL_XT
I made a simple code below to check if the clock frequency is correct.
#pragma config PLLDIV = 1
#pragma config CPUDIV = OSC1_PLL2
#pragma config FOSC = XTPLL_XT
#include <xc.h>
#define _XTAL_FREQ 4000000
#define MyPIN LATDbits.LATD0
void main(void)
{
TRISD = 0;
while(1)
{
MyPIN = 1;
NOP();
MyPIN = 0;
NOP();
}
}
NOP() should give 1 cycle delay.
Simulation shows correctly as 41ns of HIGH and 83 seconds if LOW. This is correct for 48MHz instruction frequency.
But after programming the device using the above configuration settings, the Oscilloscope at RD0 shows HIGH and LOW with timing way low than these values
Can someone take a look and advise if the config settings are correct for 48MHz cpu clock.
Thanks for the help