积分规则 网站地图 帮助中心    
嵌入式软件 单 片 机 DSP 存储器 传感控制 光电显示
嵌入式硬件 CPLD/FPGA SOPC AD/DA 接口电路 模拟设计
I C设计 通信产品 汽车电子 电源产品 消费电子 数控系统
工业控制 军工/航天 安防产品 医疗电子 计算机外设 测试测量
供应 I C
求购 公司库

  IC 求购 销售 公司 论文 DATASHEET 参考设计 论坛
当前位置: 首页 >> 英文资料
  相关分类:
How to get the most out of a single timer on an MCU
 
作者:Ajit Basarur...   来源:EETimes    点击数:298   更新时间:2008-4-3
您可以添加到网摘 让更多人关注此文章:

    In modern-day embedded systems, microcontrollers (µC) often function as supporting processors to assist a more powerful processor in the system.

Typical embedded products need to handle a variety of asynchronous activities, such as inputs from various devices (keyboard, touch screen, etc). They also need to handle a variety of synchronous activities, such as real time clock (RTC) and generation of pulse-width modulated (PWM) signals for specific purposes (e.g. brightness control of LCD display), as shown in Fig 1.



1. Typical embedded design.

These activities are often offloaded to the microcontroller so that the main processor can be put in low power mode for the maximum possible amount of time.

With the typical constraints of an embedded system, microcontrollers need to satisfy the requirements of low-cost, low power consumption, small area footprint, execution speed, and the number of functionalities it supports, which ultimately limits the choice of the device. With all these constraints, the selected µC often has a scarcity of peripherals like timers and communication interfaces; hence, intelligent methods of using resources to their best capacity need to be devised.

For example, timers may be used for various functions such as running a real-time clock (RTC), generating pulse-width modulated (PWM) signals for supplying control voltage, remote control decoders, etc. There is a reasonable advantage if a single timer can be made to handle multiple functions, especially when there is a shortage of on-chip timers in the MCU.

This article suggests a method to incorporate the functionality of RTC and PWM waveform on a single timer in a µC. The technique has been implemented and tested on the MSP430F20xx family of microcontrollers, but the concept can be applied to any generic µC.

Configuration
By appropriate configuration, the timer module can be made to interrupt the CPU at regular intervals. Typically, a real-time clock runs at 1 Hz while a PWM signal may have a frequency in the range of a few hertz to several kilohertz.

Even with such varied requirements of interrupting frequencies, the following technique proves to be applicable on a conventional timer (for example, a 16-bit up-counting or down-counting type) or on a watchdog timer configured in interval mode.

The interrupting interval of the timer has to be set to [1 / (f * N)] seconds, where f is the desired frequency of PWM operation and N is the number of PWM levels required for the application.

For instance, if the PWM output is used to control the brightness of an LCD display, N reflects the number of discrete brightness levels which are available when using this technique. In a typical MCU, the interrupt rate is controlled by a scheme as illustrated in Fig 2.



2. Typical clock generation scheme for an MCU.

As shown in Fig 2, the timer module derives its clock from an external source or an alternate internal source, which is divided by a configurable divisor module within the timer to generate the interrupts at the desired rate.

Now consider Fig 3, which illustrates continuous interrupts being generated by the timer at a rate of (f * N) hertz. Hence, the RTC count (seconds, minutes, etc.) should be incremented for every (f * N) counts (i.e. for every one second).



3. PWM output required from MCU.

Similarly, depending on the desired PWM duty cycle, the PWM output level must be toggled at appropriate interrupt counts. This requires that a state machine be maintained within the timer interrupt service routine (ISR), which decides when to toggle the PWM output and also when to update the RTC count. The operation of such a state machine is explained by means of the flow chart shown in Figure 4.



4. Flow chart showing the program flow of the timer algorithm.
(Click this image to view a larger, more detailed version)

The following five parameters need to be defined in the algorithm:



  • f: The PWM output frequency. This frequency is constant and should be above a minimum threshold (about 20 Hz) to avoid visible flicker on the LCD display. 
     
  • N: The number of discrete PWM duty cycles which are possible to achieve using the algorithm. 
     
  • k: The level of PWM duty cycle set by the user to achieve the desired brightness level. 
     
  • C: The ISR counter, which indicates how many times program control has been handed over to the Timer ISR. 
     
  • temp: A temporary integer.

Where F, N, k, and C are integers and f * N should also be an integer.


[1] [2]  下一页



相关文章
· 基于GSM、GPS模块的手持无线线路巡护终端的设计[30]
· 基于NRF9E5射频无线遥控系统的设计[16]
· 32位MCU值得关注的技术[31]
· 基于FPGA/MCU的光电式滚转角测量仪[30]
· 16位MCU攻略[56]
热门评论排行
·江苏嵌入式Linux教育培训
·锐极LINUX驱动培训班定于
·VHDL设计中电路简化问题的
·基于实时操作系统μC/OS-
·TMS320VC5402&n

文章评论
    没有任何评论
*只显示最新10条评论。评论内容只代表网友观点,与本站立场无关。更多评论
发表评论
  * 请先[登陆]再进行评论,谢谢。
评分: 1分 2分 3分 4分 5分
内容: *
发帖须知:
一.所发文章必须遵守《互联网电子公告服务管理规定》;
二.严禁发布供求代理信息,公司介绍,产品信息等广告宣传信息;
三.严禁恶意重复发帖;
四.严禁对个人,实体,民族,国家等进行漫骂,污蔑,诽谤。
 
热点新闻 [更多]
 
印度电子工程专业的学生提
抗震救灾 电子
汶川地震牵动人心&nbs
盖茨演示超大触摸墙计算机
北京奥运门票首次内嵌RF
地震殃及IT企业&nbs
Vishay 
中国已成全球最大机顶盒生
电子纸集成芯片问世&nb
NAND Fl
 
热门下载 [更多]
 
[ ] 手把手学单片机20个例
[ ] 单片机做的智能台灯
[ ] 单片机入门书
[ ] linux系统移植开发文档
[ ] IC卡的读写程序
[ ] 8051单片机C语言彻底应用
[ 常用软件] 555定时器电路设计软件V1.2
[ 常用软件] 51定时器计算软件
[ ] ARM处理器应用开发4步骤
[ ] 实用电源电路集锦
 
论坛新帖 [更多]
 
DSP与普通MCU的区别...
如何选择DSP的电源芯片?...
如何选择外部时钟?...
系统学习Linux的11点建议...
安防...
新型高智能门禁系统...
什么是嵌入式系统...
晶振不起振什么原因啊...
FPGA电源管理问答...
[求助]外部数据存储器,供个芯...

 
赞助商 [更多]
 


 

ICP许可证号:[粤 05056597]
联系电话:010-82517432 82517615 传真: 010-82517615

版权所有 Copyright © 2006 嵌入式技术网