点亮段式液晶
前几天看了一下L053的手册
发现内置有LCD驱动外设
可以支持到5X51,
玩低功耗,段式液晶才是正道啊
就去淘宝撸了几片
噩梦开始鸟
段式液晶的管脚真多啊
小小一块就有26个管脚
原来还准备用arduino接口的
直接路上两排排母了
焊得哥眼冒金星,双手发抖
这种复杂的段式液晶真是不适合DIY
坑爹的还没完
之前没有仔细看nucleo的用户手册
开始焊接了才发现
一大堆跳线要处理
结果背板被改得稀烂
com和seg口主要集中在A口和B口
后来拿出数据手册一看
IIC外设全部集中在B口
传感器咋办啊、时钟芯片咋整啊
看样子只能软件模拟了
也好,ST的硬件IIC不碰也罢,哈哈
ST官方在固件库中给出了stm32L053-Discovery段式LCD外设的驱动例程
专门把stm32L053-Discovery的原理图找来研究了一下
根据代码,实测官方的例程完全不能够使用到这块
又啃了一晚上LCD外设的资料
终于,终于贱笑了,贱笑了......
完成显示后,直接跑步进入stop模式
发现液晶还是能够正常显示滴
上代码
void LCD_GPIO_Config(void)
{
GPIO_InitTypeDef GPIO_InitStruct;
/* ?? LCD IOPORT ?? */
__GPIOA_CLK_ENABLE();
__GPIOB_CLK_ENABLE();
__GPIOC_CLK_ENABLE();
GPIO_InitStruct.Pin = GPIO_PIN_1 | GPIO_PIN_2| GPIO_PIN_3 | GPIO_PIN_6 | GPIO_PIN_7 | GPIO_PIN_8 | GPIO_PIN_9 |GPIO_PIN_10|GPIO_PIN_15 ;
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FAST;
GPIO_InitStruct.Alternate = GPIO_AF1_LCD;
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
GPIO_InitStruct.Pin = GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_5 | GPIO_PIN_8 | GPIO_PIN_9 | GPIO_PIN_12 | GPIO_PIN_13 | GPIO_PIN_3 | GPIO_PIN_4| GPIO_PIN_11 | GPIO_PIN_10;
HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
GPIO_InitStruct.Pin = GPIO_PIN_4 | GPIO_PIN_5 | GPIO_PIN_6| GPIO_PIN_8 | GPIO_PIN_2| GPIO_PIN_3 ;
HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
}
void LCD_GLASS_Init(void)
{
/* LCD GPIO ³õʼ»¯*/
LCD_GPIO_Config();
__LCD_CLK_ENABLE(); //LCDʱÖÓʹÄÜ
/*LCD³õʼ»¯½á¹¹Ìå*/
LCDHandle.Instance = LCD;
LCDHandle.Init.Prescaler = LCD_PRESCALER_1;//CLKPS = LCDCLK
LCDHandle.Init.Divider = LCD_DIVIDER_31;
LCDHandle.Init.Duty = LCD_DUTY_1_4;
LCDHandle.Init.Bias = LCD_BIAS_1_3;//Æ«ÖÃ
LCDHandle.Init.VoltageSource = LCD_VOLTAGESOURCE_INTERNAL;//ÄÚ²¿LCDµçÔ´
LCDHandle.Init.Contrast = LCD_CONTRASTLEVEL_4;//×î´óµçѹ3.12
LCDHandle.Init.DeadTime = LCD_DEADTIME_0;
LCDHandle.Init.PulseOnDuration = LCD_PULSEONDURATION_4;
LCDHandle.Init.HighDrive = DISABLE;
LCDHandle.Init.BlinkMode = LCD_BLINKMODE_OFF;
LCDHandle.Init.BlinkFrequency = LCD_BLINKFREQUENCY_DIV32;
/* Initialize the LCD */
HAL_LCD_Init(&LCDHandle);
}
int main(void)
{
/* This sample code shows how to use STM32L0xx LCD HAL API to configures the LCD Blink
mode and Blink frequency.*/
/* STM32L0xx HAL library initialization:
- Configure the Flash prefetch, Flash preread and Buffer caches
- Systick timer is configured by default as source of time base, but user
can eventually implement his proper time base source (a general purpose
timer for example or other time source), keeping in mind that Time base
duration should be kept 1ms since PPP_TIMEOUT_VALUEs are defined and
handled in milliseconds basis.
- Low Level Initialization
*/
/* Configure the system clock */
SystemClock_Config();
LCD_GPIO_Config();
HAL_PWREx_EnableUltraLowPower();
/* LCD GLASS Initialization */
LCD_GLASS_Init();
HAL_LCD_Write(&LCDHandle, LCD_RAM_REGISTER0, 0, 0x05f33fff); //¸ù¾Ýseg¡¢com¿ÚÈ·¶¨Öµ
HAL_LCD_UpdateDisplayRequest(&LCDHandle);
HAL_LCD_Write(&LCDHandle, LCD_RAM_REGISTER2, 0, 0x05f33fff);
HAL_LCD_UpdateDisplayRequest(&LCDHandle);
HAL_LCD_Write(&LCDHandle, LCD_RAM_REGISTER4, 0, 0x05f33fff);
HAL_LCD_UpdateDisplayRequest(&LCDHandle);
HAL_LCD_Write(&LCDHandle, LCD_RAM_REGISTER6, 0, 0x05f33fff);
//Åܲ½½øÈëstopģʽ
HAL_LCD_UpdateDisplayRequest(&LCDHandle);
HAL_PWR_EnterSTOPMode(PWR_LOWPOWERREGULATOR_ON,PWR_STOPENTRY_WFI);
/* Infinite loop */
while (1)
{
}
}
注释咱都是乱码?
基本就是
初始化
显示数据
进入stop模式
限于手上的渣表
暂时没有测stop模式下的功耗
过几天撸快好点的表,再一次献上
to be continued......