基于STM8系列单片机的程控数字时钟设计,包括秒表、计时、闹钟等功能。
单片机源程序(主程序)如下:
- /* Includes ------------------------------------------------------------------*/
- #include "include.h"
- #include "Time.h"
- //#include "stdio.h"
- /* Private defines -----------------------------------------------------------*/
- u16 i = 0;
- u8 Second = 0;
- u8 Minute = 0;
- u8 Hour = 0;
- u8 SendBuf[30] = " ";
- /* Private function prototypes -----------------------------------------------*/
- /*******************************************************************************
- ****函数名称:
- ****函数功能:延时函数
- ****版本:V1.0
- ****日期:14-2-2014
- ****入口参数:需要延时的数目
- ****出口参数:无
- ****说明:
- ********************************************************************************/
- void Delay(uint16_t nCount)
- {
- while (nCount != 0)
- {
- nCount--;
- }
- }
- /* Private functions ---------------------------------------------------------*/
- void main(void)
- {
- /* Infinite loop */
- LED_Init(LED1|LED2|LED3);
- LED_Off(7);
-
- UART_Init();
- Send_Str("STM8S 时钟实验\r\n");//发送字符串
-
- Timer4_Init(0x35);
-
- __enable_interrupt();
-
- while (1)
- {
- //Time_Count();
- sprintf(SendBuf, "现在时间:%02d:%02d:%02d\r\n", Hour, Minute, Second);
- ……………………
- …………限于本文篇幅 余下代码请从51黑下载附件…………
复制代码
所有资料51hei提供下载:
Project_数字时钟(库).7z
(800.75 KB, 下载次数: 34)
|