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.

[AVR] how to write to 16 Bit timer value in MikroC AVR ?

Status
Not open for further replies.

asking

Full Member level 5
Full Member level 5
Joined
Sep 21, 2010
Messages
279
Helped
6
Reputation
12
Reaction score
6
Trophy points
1,298
Visit site
Activity points
3,377
Hi,

I had a situation where i have write 31250 to timer1 in Mikroc for AVR for ATTiny2313. But in mikroc is not accepting TCNT1 = 31250. It asks for TCNT1H & TCNT1L. so how can i create > greater than condition with hex codes ? for I want to create program to toggle led when TCNT1 total count is greater than 32150. (1 second delay) by using prescaler @ 256 and Fosc @ 8mhz.

Please help how to manipulate condition with Hex ?
 

hello,

I don't know AVR but...
31250 -> gives 0x7D96 in hexadecimal , so
Code:
TCNT1H=0x7D;
TCNT1L=0x96;

2nd solution
Code:
TCNT1H= (31250 >> 8);
TCNT1LL= (31250 & 0x00FF);


3eme solution

//or you can declare a
Code:
volatile unsigned long Valeur;

Init this value in your main program
Valeur=31250L;

and use it as
Code:
TCNT1H=Hi (Valeur);
TCNT1L=Lo (Valeur);

but this consumme 4 bytes !
so i prefer 1 rst solution...
 
Last edited:

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top