Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

To calculate timer value

Status
Not open for further replies.
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.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top