To calculate timer value

Status
Not open for further replies.

Pari Boopathy

Newbie level 6
Joined
Mar 13, 2014
Messages
14
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Visit site
Activity points
94
how to calculate the timer value for 9ms of bit with internal 16Mhz oscillator?
 

the TM4C123 is referenced in the timer-calculator program
it gives a code like this for mikroC, which should not be far from the CCS C
Code:
//Timer0 Prescaler :2; Preload = 48000; Actual Interrupt Time = 9 ms; Mode: 16bit
 
//Place/Copy this part in declaration section
void InitTimer0A(){
  SYSCTL_RCGCTIMER_R0_bit = 1;
  EnableInterrupts();
  TIMER_CTL_TAEN_bit = 0;
  TIMER0_CFG   = 4;
  TIMER0_TAMR |= 2;
  TIMER0_TAPR  = 2;
  TIMER0_TAILR = 48000;
  NVIC_IntEnable(IVT_INT_TIMER0A_16_32_bit);
  TIMER_IMR_TATOIM_bit = 1;
  TIMER_CTL_TAEN_bit   = 1;
}
 
void Timer0A_interrupt() iv IVT_INT_TIMER0A_16_32_bit {
  TIMER_ICR_TATOCINT_bit = 1;
  //Enter your code here
}
 

16 MHz as you stated in the first post
but you should download the timer calculator program, it's free and easy to play with.
 

TMR Reg value =9ms x16Mhz/4

if your timer is 8 bit load timerReg value with 255-TMR Reg value
if it is 16 bit 65535-TMR Reg value

- - - Updated - - -

TMR Reg value =9ms x16Mhz/(4xprescelar)

if your timer is 8 bit load timerReg value with 255-TMR Reg value
if it is 16 bit 65535-TMR Reg value
 

Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…