Quantcast
Channel: Processors forum - Recent Threads
Viewing all articles
Browse latest Browse all 17527

OMAP L137 Timer ticks or counter

$
0
0

Hello,

I have code already for TIMER 0:12 running with interrupt and I would like to set a separate counter ticks or timer counter that should be independent of interrupts I mean even if I disable interrupts the tick should continue running and output an accurate variable of 1 second.

I am attaching this snippet

static void setup_Timer0 (void)
{
// Set Timer0 as 32 Bit Unchain
CSL_FINST(tmr0Regs->TGCR, TMR_TGCR_TIMMODE, 32BIT_UNCHAIN);

// Remove Timer0 from Reset
CSL_FINST(tmr0Regs->TGCR, TMR_TGCR_TIM12RS, NO_RESET);
CSL_FINST(tmr0Regs->TGCR, TMR_TGCR_TIM34RS, NO_RESET);

// Select Internal Clock for Timer0 (24 MHz)
CSL_FINST(tmr0Regs->TCR, TMR_TCR_CLKSRC12, INTERNAL);
CSL_FINST(tmr0Regs->TCR, TMR_TCR_CLKSRC34, INTERNAL);

// Disable the New Timer Features
CSL_FINST(tmr0Regs->TGCR, TMR_TGCR_PLUSEN, DISABLE);
}/* setup_Timer0 */

static void Timer0_freq (void)
{
// Disable Timer0:12 to Allow for a Reset & Change in Period
CSL_FINST(tmr0Regs->TCR, TMR_TCR_ENAMODE12, DISABLE);
CSL_FINST(tmr0Regs->TCR, TMR_TCR_ENAMODE34, DISABLE);


//Set Timer 0:34 to output a signal clock every 1 sec
CSL_FINST(tmr0Regs->TCR, TMR_TCR_CP34, CLOCK);
CSL_FINST(tmr0Regs->TCR, TMR_TCR_TSTAT34, HIGH);


// Reset the Counter for Timer0:12
CSL_FINST(tmr0Regs->TIM12, TMR_TIM12_TIM12, RESETVAL);
CSL_FINST(tmr0Regs->TIM34, TMR_TIM34_TIM34, RESETVAL);

// load Timer to trigger at 100k
CSL_FINS(tmr0Regs->PRD12, TMR_PRD12_PRD12, (CSL_ASYNC_2_FREQ / 100000) * 1);
CSL_FINS(tmr0Regs->PRD34, TMR_PRD34_PRD34, CSL_ASYNC_2_FREQ );

// Enable Timer0:12 Continuously
CSL_FINST(tmr0Regs->TCR, TMR_TCR_ENAMODE12, EN_CONT);
CSL_FINST(tmr0Regs->TCR, TMR_TCR_ENAMODE34, EN_CONT);
}

and inside main I am trying to read the status bit TSTAT34

main(void)

{

for(;;)

{

   if (CSL_FEXT(tmr0Regs->TCR, TMR_TCR_TSTAT34))

     {  

// do something after one second is elapsed 

     }   

                       else 

                                   {    

                                       // do something else 

                                   }

                               }

         }

the problem is I can't have this working properly. is there any easy way of using Timer0: 34 for counting ticks without setting timer pin TM64P_OUT12 as clock and how I can read this tick or clock pulse and assign it to a variable.

Thank you for the support 


Viewing all articles
Browse latest Browse all 17527

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>