LoRa终端设备ASR6505之段式LCD

前言:STM8L15x有LCD控制器外设,不需要使用额外的芯片,可以直接驱动段式LCD。ASR6505预留了最大4COM、18SEG的LCD接口,即就是开发板最右边的接口。

1、LCD驱动电源

软件来选择VLCD的电源,如果使用内部供电,则需要VLCD引脚断开(P3跳线帽断开),反之闭合。

2、ASR6505 LCD相关引脚与STM8L对应关系

3、段式LCD

4、LCD参数

参数:Bias偏置电压是1/3,Duty占空比是1/4,需要4个COM口和12个SEG口。

连接:ASR6505对应连接LCD也是用COM0-COM3(对应LCD的Pin1-Pin4),SEG0-SEG12(对应LCD的Pin5-Pin16)。

5、STM8L的LCD的SEG引脚使能

由上面的图可知,连接LCD需要ASR6505的SEG0-SEG11,对应到STM8L上面就是SEG4-SEG9、SEG14-SEG17、SEG40-SEG41,共12个SEG口,在下图在用红圈标了出来。

6、段式LCD点亮分析

查看LCD规格书可知,点亮第一个“点”需要往对应的缓存(LCD_RAM)写1,下面是STM8L的LCD_RAM表和段式LCD的映射表:

7、实验设计

驱动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-7
  LCD_PortMaskConfig(LCD_PortMaskRegister_1, 0xC3); //SEG8-9,SEG14-15
  LCD_PortMaskConfig(LCD_PortMaskRegister_2, 0x3F); //SEG16-21
  LCD_PortMaskConfig(LCD_PortMaskRegister_3, 0x00); //NONE
  LCD_PortMaskConfig(LCD_PortMaskRegister_4, 0x00); //MONE
  LCD_PortMaskConfig(LCD_PortMaskRegister_5, 0x0F); //SEG40-43

  LCD_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、实验现象

《从0到1搭建LoRa物联网》系列文章推荐:

LoRa物联网的架构

LoRaWAN终端开发

LoRa终端设备之国产ASR6505软硬件

LoRa终端设备ASR6505普通GPIO操作

LoRa终端设备ASR6505驱动DHT11

LoRa终端设备ASR6505之ADC采样

LoRa终端设备ASR6505之I2C通信

举报

扫码关注云+社区

领取腾讯云代金券

,,