Timing problem in At tiny 13

Status
Not open for further replies.

zerostar

Member
Hi,

How to calculate the time correctly when programming At tiny 13?

I want to delay 4s in 9.6mHz At tiny 13, What is the time should I use?

Also, the delay time is changing and not keep as constant when testing, any reason for that?

Thanks.!
 
To get exact timing sources on an AVR Controller, you should use a Timer that generates Interrupts.
At 9,6MHz and a 8 Bit Timer You had to use a Prescaler for the Timer - I think 1024 goes OK.
When the Count's of an Overflow Register ( RAM Variable ), thats countet up in every Interrupt routine achieves his goal value, you can set a flag, or do some action you want.
To get exact 4 Seconds, you have to preload the TCNT register of the used Timer.
To check the Timing you can simulate your Code in AVR Studio 4.xx or 5.xx. So You can check if Your calculations are right.
 
i know how to programme attiny13 by arduino,
however, the delay time is not right.

I want to delay 4s in 9.8mHz MCU, so that : 4000/9.8=408.1ms,(am i right?)

but it doesnt work
 
Opps... this is exactly my problem,thank!
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…