Internal Oscillator selection problem

Internal Oscillator selection problem

Postby raadyhere » Wed Sep 17, 2014 12:55 pm

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
and CLKDIVbits.RCDIV = 0; // FRC post scalar bits .

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: Select all
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;
 }
}
raadyhere
 
Posts: 2
Joined: Wed Sep 17, 2014 12:52 pm
Location: Stockholm, Sweden
PIC experience: Professional 2-5 years with MCHP products

Re: Internal Oscillator selection problem

Postby AussieSusan » Thu Sep 18, 2014 5:06 am

I have written a reply to you in the Microchip forum.
(I read that and then come to this forum when the frustration level reaches critical, or I have read all I want to there!)
Susan
AussieSusan
Verified identity
 
Posts: 76
Joined: Mon Jun 16, 2014 4:45 am
PIC experience: Experienced Hobbyist


Return to Oscillator

Who is online

Users browsing this forum: No registered users and 1 guest

cron