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.

[SOLVED] 16 bit timer in avr attiny88

Status
Not open for further replies.

sammey_geek

Junior Member level 1
Joined
May 22, 2013
Messages
15
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Location
india
Activity points
1,395
hi,...
i am using a dimmer in my project..for that i want to intialise a 16 bit timer and for every 2.5ms,5ms,7.5ms..it has to generate interrupt....the time period of the clock must 10ms.....can anyone tell me...how to make the timer to generate interrupt at 2.5ms, 5ms, and 7.5 ms....




thank you,
 


Code C - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
//Timer1 Prescaler = 0; Preload = 10000; Actual Interrupt Time = 2.5 ms
 
//Place/Copy this part in declaration section
void InitTimer1(){
  SREG_I_bit = 1; 
  OCR1AH = 0x27; 
  OCR1AL = 0x10;
  TCCR1A = 0x80;
  TCCR1B |= 0x09; 
  OCIE1A_bit = 1; 
}
 
void Timer1Overflow_ISR() org IVT_ADDR_TIMER1_COMPA {
  //Enter your code here 
}
 
 
 
 
//Timer1 Prescaler = 0; Preload = 20000; Actual Interrupt Time = 5 ms
 
//Place/Copy this part in declaration section
void InitTimer1(){
  SREG_I_bit = 1; 
  OCR1AH = 0x4E; 
  OCR1AL = 0x20;
  TCCR1A = 0x80;
  TCCR1B |= 0x09; 
  OCIE1A_bit = 1; 
}
 
void Timer1Overflow_ISR() org IVT_ADDR_TIMER1_COMPA {
  //Enter your code here 
}
 
 
//Timer1 Prescaler = 0; Preload = 30000; Actual Interrupt Time = 7.5 ms
 
//Place/Copy this part in declaration section
void InitTimer1(){
  SREG_I_bit = 1; 
  OCR1AH = 0x75; 
  OCR1AL = 0x30;
  TCCR1A = 0x80;
  TCCR1B |= 0x09; 
  OCIE1A_bit = 1; 
}
 
void Timer1Overflow_ISR() org IVT_ADDR_TIMER1_COMPA {
  //Enter your code here 
}

 
thank you sir,

SREG_I_bit = 1; this is for enabling the global interrupt right?? ......
OCIE1A_bit = 1; it is also sets I bit in SREG ...why we need to enbale it again..if we already enabled global interrupt by SREG_I_bit = 1;


and the values which u have given on comapre register OCR1AH & OCR1AL are the timer count value for required delay??
can u post the formula for calculating timer count value for required delay......
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top