在c中为时钟使用定时器中断需要一些帮助

时间:2014-03-18 14:05:32

标签: c timer interrupt microcontroller clock

我制作了我的电路,并在7段显示屏上显示4个不同的数字,小时:分钟格式。我现在想要它使用定时器中断,并且它可以连续运行时间使用小秒钟等小时,所以甚至更小的分​​钟,只是为了看它是否正常工作。这就是我需要帮助的时候我不知道如何使用定时器中断,只需将此作为下一步。谢谢

这是迄今为止使用P89c668微控制器的电路 - http://imgur.com/YJKQ206 [1]唯一不同的是我用缓冲器而不是晶体管

1 个答案:

答案 0 :(得分:1)

我对你的微控制器不熟悉,但校长是一样的。

1.Use an 8 or 16 bit timer.
2.Set specific bits in registers to accuratelly set the interrupt interval
3.When the timer overflows an interrupt happens(a function is called automatically)
4.In this function you increase a variable.
5.Translate the (variable * interrupt interval) to hours and minutes.

瓦尔特