Hi,
I have been working with the internal oscillator of PIC30F5011, and I followed these steps for calculation of timer
/****************************************************************************************
* Timer Delay Calculations used:
* 1. Crystal Source Frequency Fosc
* 2. Timer Frequency Ftimer = Fosc / 4
* 3. Using a Prescalar 1:8, then
* Ftimerpre = Ftimer / scalar value
* 4. Time Interval Ttimer = 1/Ftimerpre
* 5. To calculate the value to be filled in Timer rolling over
* register to generate 10m sec delay :
* No of count for 10 msec delay = 10 ms / Ttimer
****************************************************************************************/
so my calculations
for delay timer with no PLL is 2303 , PLL 4 is 9212.5 ~ 9213, PLL 8 is 18424
when ever I load PR value as 2303 the timer is working fine, and remaining rest it doesn't.
From this i knew despite the PLL that i apply i needed to load the calculations that made for PLL.
The thing I couldn't understand is when ever I am using an external oscillator (8MHz) it all working fine (for the calculations made fosc multiplied by pll), should I not apply PLL multiplied to Fosc while I am using internal oscillator ?
Here is the piece of code timer code I used
Code:
void INIT_TIMER(void)
{
TRISGbits.TRISG12 = 0; // setting MCLR LED as output port
LATGbits.LATG12 = 1; // setting on MCLR LED.
T1CON = 0; // Disable Timer and reset
TMR1 = 0x0000; // Clear timer register
PR1 = _T1_TIME; // Load the Period Value of 10m sec.
// _T1_TIME = 2303 made from calculations.
IPC0bits.T1IP = 7; // set timer 1 interrupt priority level.
IFS0bits.T1IF = 0; // Clear Timer1 Interrupt Flag
IEC0bits.T1IE = 1; // Enable Timer1 interrupt
T1CONbits.TCKPS = 0b01; // Select 1:8 Prescaler
T1CONbits.TCS = 0; // Enable Internal clock (FOSC/4)
T1CONbits.TON = 1; // Start Timer
}
Regards,
Raady