资源简介
该程序是基于STM8L系列单片机和TM1638键盘数码管驱动芯片通过单片机内置RTC模块完成的实时时钟,该程序不仅有利于对RTC的学习和数码管键盘驱动芯片的掌握!
代码片段和文件信息
/**
******************************************************************************
* @file delay.c
* @author Microcontroller Division
* @version V1.2.0
* @date 09/2010
* @brief delay functions
******************************************************************************
* @copy
*
* THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
* WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
* TIME. AS A RESULT STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY
* DIRECT INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
* FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
* CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
*
* © COPYRIGHT 2010 STMicroelectronics
*/
/* Includes ------------------------------------------------------------------*/
#include “stm8l15x_clk.h“
/**
* @brief delay for some time in ms unit
* @caller auto_test
* @param n_ms is how many ms of time to delay
* @retval None
*/
void delay_ms(u16 n_ms)
{
/* Init TIMER 4 */
CLK_PeripheralClockConfig(CLK_Peripheral_TIM4 ENABLE);
/* Init TIMER 4 prescaler: / (2^6) = /64 */
TIM4->PSCR = 6;
/* HSI div by 1 --> Auto-Reload value: 16M / 64 = 1/4M 1/4M / 1k = 250*/
TIM4->ARR = 250;
/* Counter value: 2 to compensate the initialization of TIMER*/
TIM4->CNTR = 2;
/* clear update flag */
TIM4->SR1 &= ~TIM4_SR1_UIF;
/* Enable Counter */
TIM4->CR1 |= TIM4_CR1_CEN;
while(n_ms--)
{
while((TIM4->SR1 & TIM4_SR1_UIF) == 0) ;
TIM4->SR1 &= ~TIM4_SR1_UIF;
}
/* Disable Counter */
TIM4->CR1 &= ~TIM4_CR1_CEN;
}
/**
* @brief delay for some time in 10us unit(partial accurate)
* @caller auto_test
* @param n_10us is how many 10us of time to delay
* @retval None
*/
void delay_10us(u16 n_10us)
{
/* Init TIMER 4 */
CLK_PeripheralClockConfig(CLK_Peripheral_TIM4 ENABLE);
/* prescaler: / (2^0) = /1 */
TIM4->PSCR = 0;
/* SYS_CLK_HSI_DIV1 Auto-Reload value: 16M / 1 = 16M 16M / 100k = 160 */
TIM4->ARR = 160;
/* Counter value: 10 to compensate the initialization of TIMER */
TIM4->CNTR = 10;
/* clear update flag */
TIM4->SR1 &= ~TIM4_SR1_UIF;
/* Enable Counter */
TIM4->CR1 |= TIM4_CR1_CEN;
while(n_10us--)
{
while((TIM4->SR1 & TIM4_SR1_UIF) == 0) ;
TIM4->SR1 &= ~TIM4_SR1_UIF;
}
/* Disable Counter */
TIM4->CR1 &= ~TIM4_CR1_CEN;
CLK_PeripheralClockConfig(CLK_Peripheral_TIM4 DISABLE);
}
void delay_nus(u8 n_us)
{
u8 i;
for(i=0;i {
asm(“nop“);
asm(“nop“);
asm(“nop“);
asm(“nop“);
asm(“nop“);
asm(“nop“);
asm(“nop“);
asm(“nop“);
asm(“nop“);
}
}
/******************* (C) COPYRIGHT 2010 STMicroelectronics *****END OF FILE****/
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 278528 2011-04-15 21:57 TM1638芯片+DS1302驱动共阴数码管时钟.doc
----------- --------- ---------- ----- ----
278528 1
相关资源
- WebRTC噪声抑制算法源码
- webRTC服务器端代码
- RTCMV3V2CMR.rar
- 基于 STM32 的 RTC 实时时钟
- WebRTC零基础开发者教程(纯净版)
- USB CCID 规范
- RTC4扫描卡开发文档
- 正点原子MINI板子万年历
- 串口屏动态实时显示时间
- PowerTCP Telnet for .NET 4.4.5 破解去除试用
- WebRTC学习之四:最简单的语音聊天
- STM32+ESP8266+smartconfig配网.zip
- 有关绘图类chartctrl的说明,源码和
- BH1750+内部RTC stm32毕设验证成功
- KRTCLUB2.1.2.69.rar
- 基于STM32ZET6正点原子战舰板的IIC接口
- LearningWebRTC中文版.pdf
- 基于STM32+W5500, 移植Ethernet文件并基于
- ChartControl显示非连续点数据
- STM32G071低功耗模式进入退出RTC和按键
- STM32L15X的低功耗模式及RTC唤醒测试
- 基于stm32简单万年历设计
- webrtc教程
- webrtcDemo150521
- RTCA DO-160E中文版
- kurento webRTC
- webrtc教程v0.3
- webrtc视频通话 浏览器
- 智能手环计步+温湿度+RTC实时时间+心
- learning webrtc 中文版
评论
共有 条评论