Hello,
I think I have succed to get a 1MHz interrupt with the timer0_34.
I dont change the PLL so I think that I have a 25MHz signal which is on my CPU (I have check all the registers of the PLL and it seems to be ok).
My PRD function has a period of 500ms and I use a software counter to get 1second.
//--------------------------------------------------------- // main.c //--------------------------------------------------------- #include "INTERRUPT_FULLcfg.h" //BIOS include file #include "framework.h" int sec_cnt=0; double freq_cnt=0; void configureTimer0(void); void main(void) { initAll(); configureTimer0(); //configureTimer0(); // configureTimer1(); return; // return to BIOS scheduler } void dipPRD(void) { LED_toggle(LED_1); LED_toggle(LED_2); sec_cnt++; if(sec_cnt == 2) { sec_cnt = 0; // printf("cnt value ; %d",freq_cnt); freq_cnt = 0; } } //--------------------------------------------------------- //--------------------------------------------------------- void intFct0(void) { freq_cnt = freq_cnt+1; } void configureTimer0(void) { //HWI_INT5, interrupt selection numbber = 64 (Timer64P0 Interrupt34) TMR0->GPDATA_GPDIR = GPDIRO12 | GPDIRI12; // disable all related interrupts TMR0->TGCR = 0x00000000; // stop and reset timer 0 TMR0->TCR = 0x00000000; // config timer0 in 32-bit unchained mode, remove timer0 (3:4) from reset SETBIT(TMR0->TGCR, PRESCALER(1) | TIMMODE_32BIT_UNCHAINED | TIM34RS ); // config timer 0 3:4 timer and period registers 0x TMR0->TIM34 = 0x00000000; TMR0->PRD34 = 0x00000018; //count up to 24 SETBIT(TMR0->TCR, ENAMODE34_CONT); // start timer0 3:4, continuous mode }
on a breakpoint in "if(sec_cnt == 2) {" the value of freq_cnt is 480019.0, close to 500k
and I want 1MHz
Where am I wrong?
Thank you very much
Simon.