完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
本帖最后由 1563661808 于 2014-4-3 10:18 编辑
[size=11.818181991577148px]LCD部分:[size=11.818181991577148px] [size=11.818181991577148px] [size=11.818181991577148px]
stm8l15x_io.rar
(944.82 KB, 下载次数: 21
)
#include "periph_lcd.h" lcd_code_item_t LCD_CODE_TAB[]= { [LCD_CHAR_0] ={.COM0_L=1,.COM0_H=0,.COM1_L=1,.COM1_H=1,.COM2_L=0,.COM2_H=1,.COM3_L=1,.COM3_H=1,}, [LCD_CHAR_1] ={.COM0_L=0,.COM0_H=0,.COM1_L=0,.COM1_H=1,.COM2_L=0,.COM2_H=1,.COM3_L=0,.COM3_H=0,}, [LCD_CHAR_2] ={.COM0_L=1,.COM0_H=0,.COM1_L=1,.COM1_H=0,.COM2_L=1,.COM2_H=1,.COM3_L=0,.COM3_H=1,}, [LCD_CHAR_3] ={.COM0_L=1,.COM0_H=0,.COM1_L=0,.COM1_H=1,.COM2_L=1,.COM2_H=1,.COM3_L=0,.COM3_H=1,}, [LCD_CHAR_4] ={.COM0_L=0,.COM0_H=0,.COM1_L=0,.COM1_H=1,.COM2_L=1,.COM2_H=1,.COM3_L=1,.COM3_H=0,}, [LCD_CHAR_5] ={.COM0_L=1,.COM0_H=0,.COM1_L=0,.COM1_H=1,.COM2_L=1,.COM2_H=0,.COM3_L=1,.COM3_H=1,}, [LCD_CHAR_6] ={.COM0_L=1,.COM0_H=0,.COM1_L=1,.COM1_H=1,.COM2_L=1,.COM2_H=0,.COM3_L=1,.COM3_H=1,}, [LCD_CHAR_7] ={.COM0_L=0,.COM0_H=0,.COM1_L=0,.COM1_H=1,.COM2_L=0,.COM2_H=1,.COM3_L=0,.COM3_H=1,}, [LCD_CHAR_8] ={.COM0_L=1,.COM0_H=0,.COM1_L=1,.COM1_H=1,.COM2_L=1,.COM2_H=1,.COM3_L=1,.COM3_H=1,}, [LCD_CHAR_9] ={.COM0_L=1,.COM0_H=0,.COM1_L=0,.COM1_H=1,.COM2_L=1,.COM2_H=1,.COM3_L=1,.COM3_H=1,}, [LCD_CHAR_OFF]={.COM0_L=0,.COM0_H=0,.COM1_L=0,.COM1_H=0,.COM2_L=0,.COM2_H=0,.COM3_L=0,.COM3_H=0,}, }; void LCD_Open(void) { CLK_PeripheralClockConfig(CLK_Peripheral_LCD,ENABLE); CLK_RTCClockConfig(CLK_RTCCLKSource_HSI,CLK_RTCCLKDiv_64); LCD_Init(LCD_Prescaler_8,LCD_Divider_18,LCD_Duty_1_4,LCD_Bias_1_3,LCD_VoltageSource_External); LCD_PortMaskConfig(LCD_PortMaskRegister_0, 0xff); LCD_PortMaskConfig(LCD_PortMaskRegister_1, 0x03); LCD_ContrastConfig(LCD_Contrast_3V0); LCD_DeadtimeConfig(LCD_DeadTime_0); LCD_PulseOnDurationConfig(LCD_PulseOnDuration_7); LCD_Cmd(ENABLE); } void LCD_DispCharOnIndex(uint8ch, uint8 index) { if(index>=LCD_INDEX_MAX_COUNT) { return ; } uint8lcd_code=LCD_CODE_TAB[ch].Byte; if(lcd_code & BIT_MAST_COM0_L) { bit_arry_set_bit((void *)LCD->RAM,28*0+index*2); } else { bit_arry_clr_bit((void *)LCD->RAM,28*0+index*2); } if(lcd_code & BIT_MAST_COM0_H) { bit_arry_set_bit((void *)LCD->RAM,28*0+index*2+1); } else { bit_arry_clr_bit((void *)LCD->RAM,28*0+index*2+1); } if(lcd_code & BIT_MAST_COM1_L) { bit_arry_set_bit((void *)LCD->RAM,28*1+index*2); } else { bit_arry_clr_bit((void *)LCD->RAM,28*1+index*2); } if(lcd_code & BIT_MAST_COM1_H) { bit_arry_set_bit((void *)LCD->RAM,28*1+index*2+1); } else { bit_arry_clr_bit((void *)LCD->RAM,28*1+index*2+1); } if(lcd_code & BIT_MAST_COM2_L) { bit_arry_set_bit((void *)LCD->RAM,28*2+index*2); } else { bit_arry_clr_bit((void *)LCD->RAM,28*2+index*2); } if(lcd_code & BIT_MAST_COM2_H) { bit_arry_set_bit((void *)LCD->RAM,28*2+index*2+1); } else { bit_arry_clr_bit((void *)LCD->RAM,28*2+index*2+1); } if(lcd_code & BIT_MAST_COM3_L) { bit_arry_set_bit((void *)LCD->RAM,28*3+index*2); } else { bit_arry_clr_bit((void *)LCD->RAM,28*3+index*2); } if(lcd_code & BIT_MAST_COM3_H) { bit_arry_set_bit((void *)LCD->RAM,28*3+index*2+1); } else { bit_arry_clr_bit((void *)LCD->RAM,28*3+index*2+1); } } void LCD_DispOffOnIndex(uint8index) { LCD_DispCharOnIndex(LCD_CHAR_OFF,index); } void LCD_DispOffOnAllIndex(void) { for(uint8 i=0;i LCD_DispCharOnIndex(LCD_CHAR_OFF,i); } } void LCD_DispUint16(uint16num, uint8 blank) { uint8 bcd[__MAX(5,LCD_INDEX_MAX_COUNT)]={0}; uint8 bcd_index; uint8 lcd_index; uint8 index_max_count=__MAX(5,LCD_INDEX_MAX_COUNT); u16_to_bcd_5(num,bcd); bcd_index=index_max_count-1; for(;(bcd[bcd_index]==0)&&(bcd_index!=0);bcd_index--) { lcd_index=index_max_count-1-bcd_index; LCD_DispCharOnIndex(LCD_CHAR_OFF,lcd_index); } for(;bcd_index!=0xff;bcd_index--) { lcd_index=index_max_count-1-bcd_index; LCD_DispCharOnIndex(bcd[bcd_index],lcd_index); } } #include "stm8l15x.h" #include "uni_int.h" #include "delay.h" #include "periph_lcd.h" int main() { LCD_Open(); uint16 num=100; while(1) { num--; LCD_DispUint16(num,LCD_CHAR_OFF); delay(); } } |
|
相关推荐
|
|
感谢分享!!!
感谢分享!!! |
|
|
|
|
|
感谢分享!!!
感谢分享!!! |
|
|
|
|
|
2136 浏览 1 评论
AD7686芯片不传输数据给STM32,但是手按住就会有数据。
1970 浏览 3 评论
4566 浏览 0 评论
如何解决MPU-9250与STM32通讯时,出现HAL_ERROR = 0x01U
2116 浏览 1 评论
hal库中i2c卡死在HAL_I2C_Master_Transmit
2629 浏览 1 评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-12-24 05:08 , Processed in 0.558483 second(s), Total 44, Slave 35 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号