#include "stm32f10x.h" // Device header
#include "delay.h"
#define GPIO_CLKD1(x) GPIO_WriteBit(GPIOD,GPIO_Pin_1,(BitAction)(x)); //CLK
#define GPIO_SDAD2(x) GPIO_WriteBit(GPIOD,GPIO_Pin_2,(BitAction)(x)); //CLK
//小时
struct hour_1{
unsigned char shi;
unsigned char ge;
}Hour;
//分钟
struct min_1{
unsigned char shi;
unsigned char ge;
}Min;
const unsigned char SEGData[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f};//1-9
const unsigned char SEGDataDp[]={0xbf,0x86,0xdb,0xcf,0xe6,0xed,0xfd,0x87,0xff,0xef}; //有小数点只用于地址0xc1
void Out_SD()
{
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOD,ENABLE);
GPIO_InitTypeDef GPIO_InitStruct;
GPIO_InitStruct.GPIO_Mode=GPIO_Mode_Out_PP;
GPIO_InitStruct.GPIO_Pin=GPIO_Pin_1|GPIO_Pin_2;
GPIO_InitStruct.GPIO_Speed=GPIO_Speed_50MHz;
GPIO_Init(GPIOD,&GPIO_InitStruct);
}
void TM1637_start()
{
GPIO_CLKD1(1);
GPIO_SDAD2(1);
Delay_us(150);
GPIO_SDAD2(0);
STM32驱动TW1637四位数码管模块计数 TIM输出PWM
于 2022-05-13 08:46:38 首次发布