英锐恩单片机论坛,Microchip单片机,模拟器件,接口电路,麦肯单片机,单片机应用交流

 找回密码
 立即注册
搜索
电子烟方案单片机单片机开发深圳单片机开发
单片机方案国产单片机8位单片机电子烟方案开发
查看: 2867|回复: 0
打印 上一主题 下一主题

CCS-C中,中断函数如何写?(例如Timer0中断)供参考

[复制链接]
跳转到指定楼层
1#
发表于 2009-5-18 14:01:11 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
#INT_TIMER0
Timer0_Interrupt( )
{
   ......
}
void main( )
{
   ......
   enable_interrupts(INT_TIMER0);
   enable_interrupts(GLOBAL);
   ......
}





设置初值
see help file
Syntax: set_timer0(value)     or   set_rtcc (value)
set_timer1(value)
set_timer2(value)
set_timer3(value)
Parameters: Timers 1 and 3 get a 16 bit int.
Timer 2 gets an 8 bit int.
Timer 0 (AKA RTCC) gets an 8 bit int except on the PIC18XXX where it needs a 16 bit int.
Returns: undefined
Function: Sets the count value of a real time clock/counter.  RTCC and Timer0 are the same.  
All timers count up.  When a timer reaches the maximum value it will flip over to 0 and continue counting (254, 255, 0, 1, 2...).
Availability: Timer 0 - All devices
Timers 1,2 - Most but not all PCM devices
Timer 3 - Only PIC18XXX
Requires: Nothing
Examples:
// 20 mhz clock, no prescaler, set timer 0
// to overflow in 35us
set_timer0(81); // 256-(.000035/(4/20000000))

Example Files: ex_patg.c
Also See: set_timer1(), get_timerX()
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

关闭

站长推荐上一条 /1 下一条

小黑屋|公司首页|Microchip单片机,模拟器件,接口电路,麦肯单片机,单片机应用交流 ( 粤ICP备09008620号 )

GMT+8, 2024-12-26 09:44 , Processed in 0.059189 second(s), 22 queries .

Powered by Discuz! X3.2

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表