ATtiny2313Timers-Counters.ppt

上传人:boatfragile160 文档编号:378700 上传时间:2018-10-09 格式:PPT 页数:14 大小:629.50KB
下载 相关 举报
ATtiny2313Timers-Counters.ppt_第1页
第1页 / 共14页
ATtiny2313Timers-Counters.ppt_第2页
第2页 / 共14页
ATtiny2313Timers-Counters.ppt_第3页
第3页 / 共14页
ATtiny2313Timers-Counters.ppt_第4页
第4页 / 共14页
ATtiny2313Timers-Counters.ppt_第5页
第5页 / 共14页
亲,该文档总共14页,到这儿已超出免费预览范围,如果喜欢就下载吧!
资源描述

1、ATtiny2313 Timers/Counters,CS-423 Dick Steflik,What Do You Use Timers For?,Timing of events (internal or external) Scheduling Events Measuring the width of a pulse Speed control of motors (PWM) Generation of complex waveforms Frequency generation (sounds),The concept of using a timer/counter,Counter

2、s run asynchronously to your code Can be setup to start based on an internal or external event Can generate interrupts Can signal to a pin,Example,To time a piece of code: Initial the counter to 0, have it interrupt on overflow Interrupt handler should count overflows Start the counter Run your code

3、 At end of code read counter and add to number of overflows to get total time,Example,To time an incoming pulse/event: Setup interrupts on rising and falling edge of pulse and overflow of counter In handler for rising edge start counter In handler for overflow, count the overflows In handler for fal

4、ling edge read counter and add overflows to get time of pulse/event,Example,Motor control: Use counter to generate a pulse train to control speed of DC motors Full speed = full power (infinitely wide pulse Low speed = narrow pulses with wide down time 50% speed = equal up and down times Can only con

5、trol very small motoers directly, must use high power transistors to drive bigger motors This is came idea as intermittent wipers on a car,2 Timer/Counter Units,8-bit Timer/Counter0 w/PWM 16-bit Timer/Counter1 Timer/Counter1 and Timer/Counter0 prescalers,8-bit Timer/Counter0,Single channel counter F

6、requency Generator External Event Counter 10-bit clock prescaler Only used with internal clock Scale by: 1, 8, 64, 256, 1024,8-bit Timer/Counter0,8-bit Timer/Counter0,Sample code can be found at: http:/ Timer/Counter1,Modes of Operation,Normal Mode always counts up, no clear, counter just overruns Clear Timer on Compare match (CTC mode) Fast PWM Mode Phase Correct PWM mode Phase and Frequence Correct PWM mode,16-bit Timer/Counter1,Sample code can be found at: http:/

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 教学课件 > 大学教育

copyright@ 2008-2019 麦多课文库(www.mydoc123.com)网站版权所有
备案/许可证编号:苏ICP备17064731号-1