当前位置:网站首页>STM8L 液晶数码管驱动,温度计液晶屏显示
STM8L 液晶数码管驱动,温度计液晶屏显示
2022-08-08 23:04:00 【Jacky_Lu】
启动液晶驱动 stm8 支持 4com 28 seg 可以显示 28*4=112点的液晶
void LCD_Configuration(void)
{
/* Enable RTC CLK */
CLK_PeripheralClockConfig(CLK_Peripheral_RTC, ENABLE);
/* Choice CLK Source, HSI_Freq = 16M, RTC_Freq = 500Khz*/
CLK_RTCClockConfig(CLK_RTCCLKSource_HSI,CLK_RTCCLKDiv_32);
/* Enable LCD CLK */
CLK_PeripheralClockConfig(CLK_Peripheral_LCD, ENABLE);
/* Frequence = 500K/(32+16)? Frame_Freq = Frequence/Duty = 60Hz */
LCD_Init(LCD_Prescaler_32, LCD_Divider_16, LCD_Duty_1_4,
LCD_Bias_1_3, LCD_VoltageSource_Internal);
/* Enable PM */
LCD_PortMaskConfig(LCD_PortMaskRegister_0, 0xFF);
LCD_PortMaskConfig(LCD_PortMaskRegister_1, 0x0F);
LCD_PortMaskConfig(LCD_PortMaskRegister_2, 0x00);
LCD_PortMaskConfig(LCD_PortMaskRegister_3, 0x00);
LCD_PortMaskConfig(LCD_PortMaskRegister_4, 0x00);
LCD_PortMaskConfig(LCD_PortMaskRegister_5, 0x00);
/*??LCD_Contrast_Level_7: Medium Density / High Density Maximum Voltage = 3.30V / 3.51V */
LCD_ContrastConfig(LCD_Contrast_Level_7);
/* No dead time */
LCD_DeadTimeConfig(LCD_DeadTime_0);
/*?LCD_PulseOnDuration_7: Pulse ON duration = 7/CLKprescaler */
LCD_PulseOnDurationConfig(LCD_PulseOnDuration_7);
LCD_Cmd(ENABLE);
}
根据 lcd 布线 做位表
#define CS(com,seg) (com*28+seg)
#define SMG(NUM) CS(3,2+NUM*2),CS(2,2+NUM*2),CS(1,2+NUM*2),CS(0,1+NUM*2),CS(1,1+NUM*2),CS(3,1+NUM*2),CS(2,1+NUM*2) //第一个数码管
const INT8U DispBitTab[]={
SMG(0),
SMG(1),
SMG(2),
SMG(3),
};
创建数码管对应的字符表
#define BIT0 0
#define BIT1 1
#define BIT2 2
#define BIT3 3
#define BIT4 4
#define BIT5 5
#define BIT6 6
#define BIT7 7
#define LedSeg_a ( 1<<BIT0 )
#define LedSeg_b ( 1<<BIT1 )
#define LedSeg_c ( 1<<BIT2 )
#define LedSeg_d ( 1<<BIT3 )
#define LedSeg_e ( 1<<BIT4 )
#define LedSeg_f ( 1<<BIT5 )
#define LedSeg_g ( 1<<BIT6 )
#define LedSeg_h ( 1<<BIT7 )
#define LedPin 0
// 编码计算
#define LedChar_0 LedPin ^ ( LedSeg_a |LedSeg_b |LedSeg_c |LedSeg_d |LedSeg_e |LedSeg_f )
#define LedChar_1 LedPin ^ ( LedSeg_b |LedSeg_c )
#define LedChar_2 LedPin ^ ( LedSeg_a |LedSeg_b |LedSeg_d |LedSeg_e |LedSeg_g )
#define LedChar_3 LedPin ^ ( LedSeg_a |LedSeg_b |LedSeg_c |LedSeg_d |LedSeg_g )
#define LedChar_4 LedPin ^ ( LedSeg_b |LedSeg_c |LedSeg_f |LedSeg_g )
#define LedChar_5 LedPin ^ ( LedSeg_a |LedSeg_c |LedSeg_d | LedSeg_f |LedSeg_g )
#define LedChar_6 LedPin ^ ( LedSeg_a |LedSeg_c |LedSeg_d | LedSeg_e |LedSeg_f |LedSeg_g )
#define LedChar_7 LedPin ^ ( LedSeg_a |LedSeg_b |LedSeg_c )
#define LedChar_8 LedPin ^ ( LedSeg_a |LedSeg_b |LedSeg_c | LedSeg_d |LedSeg_e |LedSeg_f |LedSeg_g )
#define LedChar_9 LedPin ^ ( LedSeg_a |LedSeg_b |LedSeg_c | LedSeg_d |LedSeg_f |LedSeg_g )
const unsigned char lednumTab[]={LedChar_0,LedChar_1,LedChar_2,LedChar_3,LedChar_4,LedChar_5,LedChar_6,LedChar_7,LedChar_8,LedChar_9,0x00};
显示数码管的程序
void dis_bcd(INT8U led_id, INT8U num) //显示子程序
{
INT8U i,pos;
led_id*=7;
num=lednumTab[num];
for(i=0;i<7;i++)
{
pos=DispBitTab[led_id];
if(num&1)
LCD->RAM[pos/8]|=BitTab[pos%8];
else
LCD->RAM[pos/8]&=~BitTab[pos%8];
++led_id;
num>>=1;
}
}
边栏推荐
- Firewall first contact
- Taro小程序跨端开发入门实战
- 【Tensorflow2】tensorflow1.x-tensorflow2.x一些接口的转变
- 【PP-YOLOv2】测试自定义的数据集
- Mysql数据库身份证统计sql数据库加密等操作
- sess.restore() 和 tf.import_meta_graph() 在使用时的一些关联
- wps表格怎么调整表格大小?wps表格调整表格大小的方法
- 如何使用 Eolink 实现 API 文档自动生成
- MES docks with Simba to realize IMEI number writing and coupling test of Spreadtrum platform
- JS中的作用域与作用域链
猜你喜欢
随机推荐
thinkphp5 if else的表达式怎么写?
用工具实现 Mock API 的整个流程
ArcPy spot number - automatically fill according to field length
全国各省市区行政代码 城市代码.txt
Free ARP
微信公众号 接口测试平台 获取自定义菜单教程
机器学习之知识点(一)
新安装Laravel Framework 6.18.35 php artisan migrate 报错
JSDay1-两数之和
windows10安装vagrant+VirtualBox搭建PHP开发环境
嵌入式驱动开发整体调试
按键精灵 for ts API 使用
影响你各应用间网速的QoS你了解吗?
设计分享|基于单片机的P0口驱动LED闪烁
Xcode creates a Dylib plugin deb project
Mysql8.0.21 Community Server远程连接报错
MySQL 5.5(Windows)的安装教程
CTFSHOW_WEB入门web213
微信小程序 wx:for 循环输出 例子
虚拟路由冗余协议VRRP——双机热备份基础