// I'm using 20MHz crystal oscillator.
void main(void)
{
InitializeSystem();
while(1)
{
USBTasks(); // USB Tasks
ProcessIO(); // See user\user.c & .h
while (1)
{
PORTD = 0xFF;
Delay10KTCYx(200);
Delay10KTCYx(200);
Delay10KTCYx(100);
PORTD = 0x00;
Delay10KTCYx(200);
Delay10KTCYx(200);
Delay10KTCYx(100);
}
}//end while
}//end main
The timing suggest that your chip is running at 16MHz. The only way this can happen is if you have the PLL output divided by 6 as the clock source, but your config has HS selected. Have you tried setting it in source, I never use MPLAB to set the config as I find it confusing.
Mike.
// USB clock source comes from the 96 MHz PLL divided by 2
// Primary oscillator used directly for system clock (no postscaler)
// Divide by 5 (20 MHz oscillator input)
CONFIG1L = 0b00100100;
// Oscillator Switchover mode disabled
// Fail-Safe Clock Monitor disabled
// HS oscillator (HS)
CONFIG1H = 0b00001100;
#pragma config WDT = OFF, LVP=OFF
#pragma config FOSC = HS, PLLDIV = 5, CPUDIV = OSC1_PLL2, USBDIV = 2
// USB clock source comes from the 96 MHz PLL divided by 2
// Primary oscillator used directly for system clock (no postscaler)
// Divide by 5 (20 MHz oscillator input)
CONFIG1L = 0b00100100;
// Oscillator Switchover mode disabled
// Fail-Safe Clock Monitor disabled
// HS oscillator (HS)
CONFIG1H = 0b00001100;
Just for understanding sake, is there any way to set the PIC registers by writing to it directly..?
Not that I am aware of. You can probably do it by using a section but I find it easier to just use the directive.
Mike.
TiagoSilva,
I guess you missed the attachment to the first post.
Mike.
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?