系列文章:
【从0到1搭建LoRa物联网】1、LoRa物联网的架构
【从0到1搭建LoRa物联网】2、终端设备开发方式
【从0到1搭建LoRa物联网】3、国产LoRa终端ASR6505软硬件
【从0到1搭建LoRa物联网】4、国产LoRa终端ASR6505普通GPIO
【从0到1搭建LoRa物联网】5、国产LoRa终端ASR6505驱动DHT11
【从0到1搭建LoRa物联网】6、国产LoRa终端ASR6505 I2C接口
1、前言
STM8L15x有LCD控制器外设,不需要使用额外的芯片,可以直接驱动段式LCD。ASR6505预留了最大4COM、18SEG的LCD接口,即就是开发板最右边的接口。
2、LCD驱动电源
软件来选择VLCD的电源,如果使用内部供电,则需要VLCD引脚断开(P3跳线帽断开),反之闭合。
3、ASR6505 LCD相关引脚与STM8L对应关系
ASR6505 LCD相关引脚与STM8L对应关系如下:
4、段式LCD
5、LCD参数
参数:Bias偏置电压是1/3,Duty占空比是1/4,需要4个COM口和12个SEG口。
连接:ASR6505对应连接LCD也是用COM0-COM3(对应LCD的Pin1-Pin4),SEG0-SEG12(对应LCD的Pin5-Pin16)。
6、STM8L的LCD的SEG引脚使能
由上面的图可知,连接LCD需要ASR6505的SEG0-SEG11,对应到STM8L上面就是SEG4-SEG9、SEG14-SEG17、SEG40-SEG41,共12个SEG口,在下图在用红圈标了出来。
7、段式LCD点亮分析
查看LCD规格书可知,点亮第一个“点”需要往对应的缓存(LCD_RAM)写1,下面是STM8L的LCD_RAM表和段式LCD的映射表:
8、代码实现
void LCD_PeriphInit(void){CLK_PeripheralClockConfig(CLK_Peripheral_LCD, ENABLE);//LCD驱动时钟门控使能LCD_DeInit( );//LCD相关寄存器恢复初值LCD_Init(LCD_Prescaler_4, LCD_Divider_16,//LCD驱动初始化,LCD刷新频率LCD_Duty_1_4, LCD_Bias_1_3,//1/4DUTY 1/3BIAS,看屏幕参数LCD_VoltageSource_Internal);//选择LCD驱动电源,外部或内部LCD_PortMaskConfig(LCD_PortMaskRegister_0, 0xF0); //SEG4-7LCD_PortMaskConfig(LCD_PortMaskRegister_1, 0xC3); //SEG8-9,SEG14-15LCD_PortMaskConfig(LCD_PortMaskRegister_2, 0x3F); //SEG16-21LCD_PortMaskConfig(LCD_PortMaskRegister_3, 0x00); //NONELCD_PortMaskConfig(LCD_PortMaskRegister_4, 0x00); //MONELCD_PortMaskConfig(LCD_PortMaskRegister_5, 0x0F); //SEG40-43LCD_ContrastConfig(LCD_Contrast_3V3);//配置对比度LCD_DeadTimeConfig(LCD_DeadTime_0); //设置死区时间LCD_PulseOnDurationConfig(LCD_PulseOnDuration_5);// 配置LCD脉冲持续时间LCD_HighDriveCmd(ENABLE);LCD_Cmd(ENABLE);}void LCD_Display(void){//对显示缓冲区操作,要结合液晶说明书 static uint8_t i=0; i++;if(i>=255){i=0;}if(i%2){LCD_WriteRAM(LCD_RAMRegister_0, 0x30|0xC0|0x03|0x00|0x00|0x00); LCD_WriteRAM(LCD_RAMRegister_1, 0x00|0x00|0x03|0xC0|0x00|0x00); LCD_WriteRAM(LCD_RAMRegister_2, 0x00|0x00|0x00|0x00|0x03|0x00); LCD_WriteRAM(LCD_RAMRegister_4, 0x03|0x0C|0x30|0x00|0x00|0x00); LCD_WriteRAM(LCD_RAMRegister_5, 0x00|0x00|0x00|0x0C|0x30|0x00); LCD_WriteRAM(LCD_RAMRegister_7, 0x30|0xC0|0x00|0x00|0x00|0x00); LCD_WriteRAM(LCD_RAMRegister_8, 0x00|0x00|0x03|0xC0|0x00|0x00); LCD_WriteRAM(LCD_RAMRegister_9, 0x00|0x00|0x00|0x00|0x03|0x00); LCD_WriteRAM(LCD_RAMRegister_11,0x03|0x0c|0x30|0x00|0x00|0x00); LCD_WriteRAM(LCD_RAMRegister_12,0x00|0x00|0x00|0x0C|0x30|0x00); LCD_WriteRAM(LCD_RAMRegister_15,0x00|0x00|0x00|0x00|0x00|0x30); LCD_WriteRAM(LCD_RAMRegister_17,0x00|0x00|0x00|0x00|0x00|0x30); LCD_WriteRAM(LCD_RAMRegister_19,0x00|0x00|0x00|0x00|0x00|0x30); LCD_WriteRAM(LCD_RAMRegister_21,0x00|0x00|0x00|0x00|0x00|0x30); }else{LCD_WriteRAM(LCD_RAMRegister_0, 0x20|0xC0|0x03|0x00|0x00|0x00); LCD_WriteRAM(LCD_RAMRegister_1, 0x00|0x00|0x03|0x80|0x00|0x00); LCD_WriteRAM(LCD_RAMRegister_2, 0x00|0x00|0x00|0x00|0x01|0x00); LCD_WriteRAM(LCD_RAMRegister_4, 0x00|0x08|0x20|0x00|0x00|0x00); LCD_WriteRAM(LCD_RAMRegister_5, 0x00|0x00|0x00|0x0C|0x30|0x00); LCD_WriteRAM(LCD_RAMRegister_7, 0x20|0x40|0x00|0x00|0x00|0x00); LCD_WriteRAM(LCD_RAMRegister_8, 0x00|0x00|0x02|0x80|0x00|0x00); LCD_WriteRAM(LCD_RAMRegister_9, 0x00|0x00|0x00|0x00|0x02|0x00); LCD_WriteRAM(LCD_RAMRegister_11,0x00|0x08|0x20|0x00|0x00|0x00); LCD_WriteRAM(LCD_RAMRegister_12,0x00|0x00|0x00|0x00|0x20|0x00); LCD_WriteRAM(LCD_RAMRegister_15,0x00|0x00|0x00|0x00|0x00|0x10); LCD_WriteRAM(LCD_RAMRegister_17,0x00|0x00|0x00|0x00|0x00|0x30); LCD_WriteRAM(LCD_RAMRegister_19,0x00|0x00|0x00|0x00|0x00|0x30); LCD_WriteRAM(LCD_RAMRegister_21,0x00|0x00|0x00|0x00|0x00|0x30); }}
9、实验现象
欢迎关注微信公众号【物联网思考】,回复关键字“ASR6505”获取资料,《从0到1搭建LoRa物联网》系列的所有软硬件资料将会分享在公众号。