Hi wp100,
thanks for the reply...but I didn't get your above instructions for the solution to my problem.
Here I would elaborate a bit more what is the problem, then u might help it accordingly:-
Here is a piece of code I've written in MPLAB X for C18 compiler:-
#include <stdio.h>
#include <stdlib.h>
#include <p18f4550.h>
#include <delays.h>
#pragma config FOSC = HSPLL_HS // 20MHz external crystal with PLL enabled
#pragma config PLLDIV = 5 // Divide by 5 to provide the 96MHz PLL with 4MHz input
#pragma config CPUDIV = OSC1_PLL2 // Divide 96MHz PLL output by 6 to get 16MHz system clock
#pragma config USBDIV = 2 // USB Clock comes from 96MHz PLL output/2
int i;
int j;
int k;
void main(void)
{
TRISD = 0x00;
PORTD=0x55;
for(k = 0; k < 5; k++)
{
for(i = 0; i < 5; i++)
{
for(j = 0; j < 1; j++ )
{
Delay10KTCYx(255);
}
PORTD = 0x55;
for (j = 0; j < 1; j++ )
{
Delay10KTCYx(255);
}
PORTD = ~PORTD;
}
for(i = 0; i < 5; i++)
{
for(j = 0; j < 1; j++ )
{
Delay10KTCYx(255);
}
PORTD = 0xFF;
for (j = 0; j < 1; j++ )
{
Delay10KTCYx(255);
}
PORTD = ~PORTD;
}
}
}
and it is working pretty fine(as it is a pretty standard for loop) in my PIC18f4550.
and in this code I have set #pragma config PLLDIV = 5 through the preprocessor as i knew that I was working with 20MHz external crystal oscillator. But I want to create a function in which programmer will set the value of oscillator as an argument and PLLDIV value will be set accordingly(not through the preprocessor and I don't want to use the last three #pragma config statements) -
e.g. setPLLDIV(int osc)
{
if (osc = 20)
PLLDIV = 5;
elseif(osc = 16)
PLLDIV = 4;
......
...... //and so on.
}
and in the similar fashion I want to set the CPUDIV0 and CPUDIV1 (4-3 bits of CONFIG1L) bits also. and it's obvious that solution of the above problem will lead to this problem's solution also.
another thing I want to ask is that is there any way to check the value of these registers (beyond 300000h) e.g. CONFIG1L , CONFIG1H, etc. in the simulator as we check of TRISB, PORTB and other SFRs and program memory in MPLAB SIM v8.84 or MPLABX Simulator.
and regarding the statements which you posted in your comment...I don't know ...where to use it...hope u get it that what is the problem and suggest some solution...