Raady Here
Full Member level 5
- Joined
- Jun 8, 2013
- Messages
- 242
- Helped
- 26
- Reputation
- 52
- Reaction score
- 26
- Trophy points
- 28
- Location
- India
- Activity points
- 1,571
PIC24FJ64GA006
MPLAB 8.88
Hi,
I have encountered two problems one with oscillator selection and timer calculation
For testing I am throwing timer clock data on lcd.
I am able to use only FNOSC_FRCDIV only, if i select FNOSC_FRC or FNOSC_FRCPLL nothing is being displayed on LCD.
I am using setting for oscillator as
_CONFIG2(POSCMOD_NONE & OSCIOFNC_OFF & FCKSM_CSECMD & FNOSC_FRCDIV & IESO_ON); // Oscillator Settings
calculation for timer that I have taken are
Fosc = 8 Mhz ( after post scaler should be divided by 1)
Fcy = Fosc/2
Fprescalar = Fcy/prescalar( i used 1:8)
Ttimer= 1/Fprescalar
value in PR1 register = 10ms / Ttimer = 5000 ( __T1_TIME)
but when I am running the clock , it runs exactly when I am loading the value as 500 instead of 5000.
am I missing some thing to configure with post scalars ?
timer I configured ..
MPLAB 8.88
Hi,
I have encountered two problems one with oscillator selection and timer calculation
For testing I am throwing timer clock data on lcd.
I am able to use only FNOSC_FRCDIV only, if i select FNOSC_FRC or FNOSC_FRCPLL nothing is being displayed on LCD.
I am using setting for oscillator as
_CONFIG2(POSCMOD_NONE & OSCIOFNC_OFF & FCKSM_CSECMD & FNOSC_FRCDIV & IESO_ON); // Oscillator Settings
calculation for timer that I have taken are
Fosc = 8 Mhz ( after post scaler should be divided by 1)
Fcy = Fosc/2
Fprescalar = Fcy/prescalar( i used 1:8)
Ttimer= 1/Fprescalar
value in PR1 register = 10ms / Ttimer = 5000 ( __T1_TIME)
but when I am running the clock , it runs exactly when I am loading the value as 500 instead of 5000.
am I missing some thing to configure with post scalars ?
timer I configured ..
Code:
void INIT_TIMER(void)
{
T1CON = 0; // Disable Timer1 for Clock and Reset.
TMR1 = 0x0000; // Clear RTC Timer Register.
PR1 = __T1_TIME; // Set Timer1 period register for 10ms
T1CONbits.TCKPS = 1; // Set Timer1 Input Clock Prescale Select bits (1:8)
IFS0bits.T1IF = 0; // Reset Timer 1 interrupt flag
IPC0bits.T1IP = 7; // Set Timer1 interrupt priority level to 7
IEC0bits.T1IE = 1; // Enable Interrrupt w.r.t Timer 1
T1CONbits.TON = 1; // Enable Timer1
}
/* Timer Interrupt */
void __attribute__((__interrupt__,no_auto_psv)) _T1Interrupt(void)
{
IFS0bits.T1IF = 0; //Clear Timer1 interrupt flag
Flag.TimerDelay_10ms = 1;
if(++ten_ms_cnt >= 100)
{
Clock();
ten_ms_cnt = 0;
}
}
Last edited: