STM32驱动TM1616程序加原理图
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了STM32驱动TM1616程序加原理图相关的知识,希望对你有一定的参考价值。
一、TM1616原理图
二、驱动程序
#include "led.h"
void led_init(void)
GPIO_InitTypeDef GPIO_InitStructure;
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOC|RCC_AHB1Periph_GPIOD|RCC_AHB1Periph_GPIOE, ENABLE);
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;
GPIO_Init(GPIOC, &GPIO_InitStructure);
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_13;
GPIO_Init(GPIOD, &GPIO_InitStructure);
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6;
GPIO_Init(GPIOE, &GPIO_InitStructure);
GPIO_SetBits(GPIOC,GPIO_Pin_0);
GPIO_SetBits(GPIOD,GPIO_Pin_13);
GPIO_SetBits(GPIOE,GPIO_Pin_6);
void led_delay(u8 i)
while(i>0)
i--;
void led_write_data(u8 data)
u8 i;
for(i=0;i<8;i++)
led_clk=0;
if(data&0x01)
led_dio=1;
else
led_dio=0;
data>>=1;
led_delay(2);
led_clk=1;
void led_show_data(u8 *showData)
led_stb=0;
led_delay(2);
led_write_data(0x00); //设置数据命令
led_stb=1;
led_delay(2);
led_stb=0;
led_delay(2);
led_write_data(0x40); //设置数据命令
led_stb=1;
led_delay(2);
led_stb=0;
led_delay(2);
led_write_data(0xc0); //设置显示地址
led_write_data(showData[0]); //设置显示数据
led_write_data(0X00); //设置显示数据
led_write_data(showData[1]); //设置显示数据
led_write_data(0X00); //设置显示数据
led_write_data(showData[2]); //设置显示数据
led_write_data(0X00); //设置显示数据
led_write_data(showData[3]); //设置显示数据
led_stb=1;
led_delay(2);
led_stb=0;
led_delay(2);
led_write_data(LED_ON|LED_BRIGHTNESS_3); //设置显示控制命令
led_stb=1;
led_delay(2);
三、完整工程下载
完整工程下载请点击
以上是关于STM32驱动TM1616程序加原理图的主要内容,如果未能解决你的问题,请参考以下文章
TM1650/AIP650数码管驱动显示STM32驱动程序HAL库