本帖最后由 jinglixixi 于 2018-11-19 09:49 编辑
从LPC11U68的资源配置看它有一个RTC计时器,它从例程看它却非常规的那种RTC,无法提供寄存器来读取/设置日期和时间值。为此在制作电子时钟时只好使用SysTick计时器来实现,此外该计时器还无法将频率值设为1HZ,所以只能自行分频来达到1HZ的秒信号,其计时效果如图所示。 电子时钟效果图
电子时钟进行计时处理函数为: - void SysTick_Handler(void)
- {
- p++;
- if(p>9)
- {
- p=0;
- s++;
- }
- if(s>59)
- {
- s=0;
- m++;
- if(m>59)
- {
- m=0;
- h++;
- if(h>24)
- {
- h=0;
- m=0;
- s=0;
- }
- }
- }
- }
复制代码
实现电子时钟的主程序为: - int main(void)
- {
- SystemCoreClockUpdate();
- Board_Init();
- LCD_GPIO_Cogfig();
- LCD5510_Init();
- LCD_prints(0,0,"LPC11U68");
- LCD_prints(0,1,"RTC TEST");
- /* Enable and setup SysTick Timer at a periodic rate */
- //TICKRATE_HZ1 =10
- SysTick_Config(SystemCoreClock / TICKRATE_HZ1);
- while (1)
- {
- LCD_printc(0,2,h/10+0x30);
- LCD_printc(1,2,h%10+0x30);
- LCD_printc(2,2,':');
- LCD_printc(3,2,m/10+0x30);
- LCD_printc(4,2,m%10+0x30);
- LCD_printc(5,2,':');
- LCD_printc(6,2,s/10+0x30);
- LCD_printc(7,2,s%10+0x30);
- }
- return 0;
- }
复制代码
|