#include "stm8l15x.h" void display_LCD(unsigned int temp); void delay(unsigned int time); void main(void) { unsigned int temp; temp=0; CLK_PeripheralClockConfig(CLK_Peripheral_RTC, ENABLE); //使能实时时钟 CLK_PeripheralClockConfig(CLK_Peripheral_LCD, ENABLE); //使能LCD时钟 CLK_RTCClockConfig(CLK_RTCCLKSource_HSI,CLK_RTCCLKDiv_8); //选择RTC时钟源 LCD_Init(LCD_Prescaler_64,LCD_Divider_16,LCD_Duty_1_4,LCD_Bias_1_3,LCD_VoltageSource_External ); //LCD初始化 delay(10); LCD_PortMaskConfig(LCD_PortMaskRegister_1,0XFE); // seg 9,10,11,12,13,14,15为seg口 LCD_PortMaskConfig(LCD_PortMaskRegister_2,0X3F); // seg 16,17,18,19,20,21,为seg口 LCD_ContrastConfig(LCD_Contrast_Level_3); //配置LCD的对比度 LCD_DeadTimeConfig(LCD_DeadTime_0); // 配置LCD液晶的死区时间 LCD_PulseOnDurationConfig(LCD_PulseOnDuration_1); // 配置LCD脉冲持续时间。 LCD_Cmd(ENABLE); //使能LCD控制器 while (1) { display_LCD(temp); temp++; if(temp==100) temp=0; } } //////**********************************************************************////////// //////*****************************LCD显示函数*****************************////////// void display_LCD(unsigned int temp) { unsigned int shi,ge; shi=temp/10; ge=temp%10; //********************十位显示********************////////// switch(shi) { case 1: { //显示十位1 // LCD_WriteRAM(LCD_RAMRegister_5,0X40); assert_param(IS_LCD_RAM_REGISTER(LCD_RAMRegister_5)); LCD->RAM[LCD_RAMRegister_5] = 0x40|(LCD->RAM[LCD_RAMRegister_5]); // LCD_WriteRAM(LCD_RAMRegister_12,0X40); assert_param(IS_LCD_RAM_REGISTER(LCD_RAMRegister_12)); LCD->RAM[LCD_RAMRegister_12] = 0x40|(LCD->RAM[LCD_RAMRegister_12]); break; } case 2: { //显示十位2 // LCD_WriteRAM(LCD_RAMRegister_2,0X08); assert_param(IS_LCD_RAM_REGISTER(LCD_RAMRegister_2)); LCD->RAM[LCD_RAMRegister_2] = 0x08|(LCD->RAM[LCD_RAMRegister_2]); // LCD_WriteRAM(LCD_RAMRegister_5,0X80); assert_param(IS_LCD_RAM_REGISTER(LCD_RAMRegister_5)); LCD->RAM[LCD_RAMRegister_5] = 0x80|(LCD->RAM[LCD_RAMRegister_5]); // LCD_WriteRAM(LCD_RAMRegister_9,0X04); assert_param(IS_LCD_RAM_REGISTER(LCD_RAMRegister_9)); LCD->RAM[LCD_RAMRegister_9] = 0x04|(LCD->RAM[LCD_RAMRegister_9]); // LCD_WriteRAM(LCD_RAMRegister_12,0XC0); assert_param(IS_LCD_RAM_REGISTER(LCD_RAMRegister_12)); LCD->RAM[LCD_RAMRegister_12] = 0xC0|(LCD->RAM[LCD_RAMRegister_12]); break; } case 3: { //显示十位3 // LCD_WriteRAM(LCD_RAMRegister_2,0X08); assert_param(IS_LCD_RAM_REGISTER(LCD_RAMRegister_2)); LCD->RAM[LCD_RAMRegister_2] = 0x08|(LCD->RAM[LCD_RAMRegister_2]); // LCD_WriteRAM(LCD_RAMRegister_5,0X40); assert_param(IS_LCD_RAM_REGISTER(LCD_RAMRegister_5)); LCD->RAM[LCD_RAMRegister_5] = 0x40|(LCD->RAM[LCD_RAMRegister_5]); // LCD_WriteRAM(LCD_RAMRegister_9,0X04); assert_param(IS_LCD_RAM_REGISTER(LCD_RAMRegister_9)); LCD->RAM[LCD_RAMRegister_9] = 0x04|(LCD->RAM[LCD_RAMRegister_9]); // LCD_WriteRAM(LCD_RAMRegister_12,0XC0); assert_param(IS_LCD_RAM_REGISTER(LCD_RAMRegister_12)); LCD->RAM[LCD_RAMRegister_12] = 0xC0|(LCD->RAM[LCD_RAMRegister_12]); break; } case 4: { //显示十位4 // LCD_WriteRAM(LCD_RAMRegister_5,0X40); assert_param(IS_LCD_RAM_REGISTER(LCD_RAMRegister_5)); LCD->RAM[LCD_RAMRegister_5] = 0x40|(LCD->RAM[LCD_RAMRegister_5]); // LCD_WriteRAM(LCD_RAMRegister_9,0X0C); assert_param(IS_LCD_RAM_REGISTER(LCD_RAMRegister_9)); LCD->RAM[LCD_RAMRegister_9] = 0x0C|(LCD->RAM[LCD_RAMRegister_9]); // LCD_WriteRAM(LCD_RAMRegister_12,0X40); assert_param(IS_LCD_RAM_REGISTER(LCD_RAMRegister_12)); LCD->RAM[LCD_RAMRegister_12] = 0x40|(LCD->RAM[LCD_RAMRegister_12]); break; } case 5: { //显示十位5 // LCD_WriteRAM(LCD_RAMRegister_2,0X08); assert_param(IS_LCD_RAM_REGISTER(LCD_RAMRegister_2)); LCD->RAM[LCD_RAMRegister_2] = 0x08|(LCD->RAM[LCD_RAMRegister_2]); //LCD_WriteRAM(LCD_RAMRegister_5,0X40); assert_param(IS_LCD_RAM_REGISTER(LCD_RAMRegister_5)); LCD->RAM[LCD_RAMRegister_5] = 0x40|(LCD->RAM[LCD_RAMRegister_5]); // LCD_WriteRAM(LCD_RAMRegister_9,0X0C); assert_param(IS_LCD_RAM_REGISTER(LCD_RAMRegister_9)); LCD->RAM[LCD_RAMRegister_9] = 0x0C|(LCD->RAM[LCD_RAMRegister_9]); // LCD_WriteRAM(LCD_RAMRegister_12,0X80); assert_param(IS_LCD_RAM_REGISTER(LCD_RAMRegister_12)); LCD->RAM[LCD_RAMRegister_12] = 0x80|(LCD->RAM[LCD_RAMRegister_12]); break; } case 6: { //显示十位6 // LCD_WriteRAM(LCD_RAMRegister_2,0X08); assert_param(IS_LCD_RAM_REGISTER(LCD_RAMRegister_2)); LCD->RAM[LCD_RAMRegister_2] = 0x08|(LCD->RAM[LCD_RAMRegister_2]); // LCD_WriteRAM(LCD_RAMRegister_5,0XC0); assert_param(IS_LCD_RAM_REGISTER(LCD_RAMRegister_5)); LCD->RAM[LCD_RAMRegister_5] = 0xC0|(LCD->RAM[LCD_RAMRegister_5]); // LCD_WriteRAM(LCD_RAMRegister_9,0X0C); assert_param(IS_LCD_RAM_REGISTER(LCD_RAMRegister_9)); LCD->RAM[LCD_RAMRegister_9] = 0x0C|(LCD->RAM[LCD_RAMRegister_9]); // LCD_WriteRAM(LCD_RAMRegister_12,0X80); assert_param(IS_LCD_RAM_REGISTER(LCD_RAMRegister_12)); LCD->RAM[LCD_RAMRegister_12] = 0x80|(LCD->RAM[LCD_RAMRegister_12]); break; } case 7: { //显示十位7 // LCD_WriteRAM(LCD_RAMRegister_5,0X40); assert_param(IS_LCD_RAM_REGISTER(LCD_RAMRegister_5)); LCD->RAM[LCD_RAMRegister_5] = 0x40|(LCD->RAM[LCD_RAMRegister_5]); // LCD_WriteRAM(LCD_RAMRegister_12,0XC0); assert_param(IS_LCD_RAM_REGISTER(LCD_RAMRegister_12)); LCD->RAM[LCD_RAMRegister_12] = 0xC0|(LCD->RAM[LCD_RAMRegister_12]); break; } case 8: { //显示十位8 // LCD_WriteRAM(LCD_RAMRegister_2,0X08); assert_param(IS_LCD_RAM_REGISTER(LCD_RAMRegister_2)); LCD->RAM[LCD_RAMRegister_2] = 0x08|(LCD->RAM[LCD_RAMRegister_2]); // LCD_WriteRAM(LCD_RAMRegister_5,0XC0); assert_param(IS_LCD_RAM_REGISTER(LCD_RAMRegister_5)); LCD->RAM[LCD_RAMRegister_5] = 0xC0|(LCD->RAM[LCD_RAMRegister_5]); // LCD_WriteRAM(LCD_RAMRegister_9,0X0C); assert_param(IS_LCD_RAM_REGISTER(LCD_RAMRegister_9)); LCD->RAM[LCD_RAMRegister_9] = 0x0C|(LCD->RAM[LCD_RAMRegister_9]); // LCD_WriteRAM(LCD_RAMRegister_12,0XC0); assert_param(IS_LCD_RAM_REGISTER(LCD_RAMRegister_12)); LCD->RAM[LCD_RAMRegister_12] = 0xC0|(LCD->RAM[LCD_RAMRegister_12]); break; } case 9: { //显示十位9 // LCD_WriteRAM(LCD_RAMRegister_2,0X08); assert_param(IS_LCD_RAM_REGISTER(LCD_RAMRegister_2)); LCD->RAM[LCD_RAMRegister_2] = 0x08|(LCD->RAM[LCD_RAMRegister_2]); // LCD_WriteRAM(LCD_RAMRegister_5,0X40); assert_param(IS_LCD_RAM_REGISTER(LCD_RAMRegister_5)); LCD->RAM[LCD_RAMRegister_5] = 0x40|(LCD->RAM[LCD_RAMRegister_5]); // LCD_WriteRAM(LCD_RAMRegister_9,0X0C); assert_param(IS_LCD_RAM_REGISTER(LCD_RAMRegister_9)); LCD->RAM[LCD_RAMRegister_9] = 0x0C|(LCD->RAM[LCD_RAMRegister_9]); // LCD_WriteRAM(LCD_RAMRegister_12,0XC0); assert_param(IS_LCD_RAM_REGISTER(LCD_RAMRegister_12)); LCD->RAM[LCD_RAMRegister_12] = 0xC0|(LCD->RAM[LCD_RAMRegister_12]); break; } } //************************************************************////// //******************个位显示******************************////// switch(ge) { case 0: { //显示个位0 // LCD_WriteRAM(LCD_RAMRegister_2,0X02); assert_param(IS_LCD_RAM_REGISTER(LCD_RAMRegister_2)); LCD->RAM[LCD_RAMRegister_2] = 0x02|(LCD->RAM[LCD_RAMRegister_2]); // LCD_WriteRAM(LCD_RAMRegister_5,0X30); assert_param(IS_LCD_RAM_REGISTER(LCD_RAMRegister_5)); LCD->RAM[LCD_RAMRegister_5] = 0x30|(LCD->RAM[LCD_RAMRegister_5]); // LCD_WriteRAM(LCD_RAMRegister_9,0X02); assert_param(IS_LCD_RAM_REGISTER(LCD_RAMRegister_9)); LCD->RAM[LCD_RAMRegister_9] = 0x02|(LCD->RAM[LCD_RAMRegister_9]); // LCD_WriteRAM(LCD_RAMRegister_12,0X30); assert_param(IS_LCD_RAM_REGISTER(LCD_RAMRegister_12)); LCD->RAM[LCD_RAMRegister_12] = 0x30|(LCD->RAM[LCD_RAMRegister_12]); break; } case 1: { //显示个位1 // LCD_WriteRAM(LCD_RAMRegister_5,0X10); assert_param(IS_LCD_RAM_REGISTER(LCD_RAMRegister_5)); LCD->RAM[LCD_RAMRegister_5] = 0x10|(LCD->RAM[LCD_RAMRegister_5]); // LCD_WriteRAM(LCD_RAMRegister_12,0X10); assert_param(IS_LCD_RAM_REGISTER(LCD_RAMRegister_12)); LCD->RAM[LCD_RAMRegister_12] = 0x10|(LCD->RAM[LCD_RAMRegister_12]); break; } case 2: { //显示个位2 // LCD_WriteRAM(LCD_RAMRegister_2,0X02); assert_param(IS_LCD_RAM_REGISTER(LCD_RAMRegister_2)); LCD->RAM[LCD_RAMRegister_2] = 0x02|(LCD->RAM[LCD_RAMRegister_2]); // LCD_WriteRAM(LCD_RAMRegister_5,0X20); assert_param(IS_LCD_RAM_REGISTER(LCD_RAMRegister_5)); LCD->RAM[LCD_RAMRegister_5] = 0x20|(LCD->RAM[LCD_RAMRegister_5]); // LCD_WriteRAM(LCD_RAMRegister_9,0X01); assert_param(IS_LCD_RAM_REGISTER(LCD_RAMRegister_9)); LCD->RAM[LCD_RAMRegister_9] = 0x01|(LCD->RAM[LCD_RAMRegister_9]); // LCD_WriteRAM(LCD_RAMRegister_12,0X30); assert_param(IS_LCD_RAM_REGISTER(LCD_RAMRegister_12)); LCD->RAM[LCD_RAMRegister_12] = 0x30|(LCD->RAM[LCD_RAMRegister_12]); break; } case 3: { //显示个位3 // LCD_WriteRAM(LCD_RAMRegister_2,0X02); assert_param(IS_LCD_RAM_REGISTER(LCD_RAMRegister_2)); LCD->RAM[LCD_RAMRegister_2] = 0x02|(LCD->RAM[LCD_RAMRegister_2]); // LCD_WriteRAM(LCD_RAMRegister_5,0X10); assert_param(IS_LCD_RAM_REGISTER(LCD_RAMRegister_5)); LCD->RAM[LCD_RAMRegister_5] = 0x10|(LCD->RAM[LCD_RAMRegister_5]); // LCD_WriteRAM(LCD_RAMRegister_9,0X01); assert_param(IS_LCD_RAM_REGISTER(LCD_RAMRegister_9)); LCD->RAM[LCD_RAMRegister_9] = 0x01|(LCD->RAM[LCD_RAMRegister_9]); // LCD_WriteRAM(LCD_RAMRegister_12,0X30); assert_param(IS_LCD_RAM_REGISTER(LCD_RAMRegister_12)); LCD->RAM[LCD_RAMRegister_12] = 0x30|(LCD->RAM[LCD_RAMRegister_12]); break; } case 4: { //显示个位4 // LCD_WriteRAM(LCD_RAMRegister_5,0X10); assert_param(IS_LCD_RAM_REGISTER(LCD_RAMRegister_5)); LCD->RAM[LCD_RAMRegister_5] = 0x10|(LCD->RAM[LCD_RAMRegister_5]); // LCD_WriteRAM(LCD_RAMRegister_9,0X03); assert_param(IS_LCD_RAM_REGISTER(LCD_RAMRegister_9)); LCD->RAM[LCD_RAMRegister_9] = 0x03|(LCD->RAM[LCD_RAMRegister_9]); // LCD_WriteRAM(LCD_RAMRegister_12,0X10); assert_param(IS_LCD_RAM_REGISTER(LCD_RAMRegister_12)); LCD->RAM[LCD_RAMRegister_12] = 0x10|(LCD->RAM[LCD_RAMRegister_12]); break; } case 5: { //显示个位5 // LCD_WriteRAM(LCD_RAMRegister_2,0X02); assert_param(IS_LCD_RAM_REGISTER(LCD_RAMRegister_2)); LCD->RAM[LCD_RAMRegister_2] = 0x02|(LCD->RAM[LCD_RAMRegister_2]); // LCD_WriteRAM(LCD_RAMRegister_5,0X10); assert_param(IS_LCD_RAM_REGISTER(LCD_RAMRegister_5)); LCD->RAM[LCD_RAMRegister_5] = 0x10|(LCD->RAM[LCD_RAMRegister_5]); // LCD_WriteRAM(LCD_RAMRegister_9,0X03); assert_param(IS_LCD_RAM_REGISTER(LCD_RAMRegister_9)); LCD->RAM[LCD_RAMRegister_9] = 0x03|(LCD->RAM[LCD_RAMRegister_9]); // LCD_WriteRAM(LCD_RAMRegister_12,0X20); assert_param(IS_LCD_RAM_REGISTER(LCD_RAMRegister_12)); LCD->RAM[LCD_RAMRegister_12] = 0x20|(LCD->RAM[LCD_RAMRegister_12]); break; } case 6: { //显示个位6 // LCD_WriteRAM(LCD_RAMRegister_2,0X02); assert_param(IS_LCD_RAM_REGISTER(LCD_RAMRegister_2)); LCD->RAM[LCD_RAMRegister_2] = 0x02|(LCD->RAM[LCD_RAMRegister_2]); // LCD_WriteRAM(LCD_RAMRegister_5,0X30); assert_param(IS_LCD_RAM_REGISTER(LCD_RAMRegister_5)); LCD->RAM[LCD_RAMRegister_5] = 0x30|(LCD->RAM[LCD_RAMRegister_5]); // LCD_WriteRAM(LCD_RAMRegister_9,0X03); assert_param(IS_LCD_RAM_REGISTER(LCD_RAMRegister_9)); LCD->RAM[LCD_RAMRegister_9] = 0x03|(LCD->RAM[LCD_RAMRegister_9]); // LCD_WriteRAM(LCD_RAMRegister_12,0X20); assert_param(IS_LCD_RAM_REGISTER(LCD_RAMRegister_12)); LCD->RAM[LCD_RAMRegister_12] = 0x20|(LCD->RAM[LCD_RAMRegister_12]); break; } case 7: { //显示个位7 // LCD_WriteRAM(LCD_RAMRegister_5,0X10); assert_param(IS_LCD_RAM_REGISTER(LCD_RAMRegister_5)); LCD->RAM[LCD_RAMRegister_5] = 0x10|(LCD->RAM[LCD_RAMRegister_5]); // LCD_WriteRAM(LCD_RAMRegister_12,0X30); assert_param(IS_LCD_RAM_REGISTER(LCD_RAMRegister_12)); LCD->RAM[LCD_RAMRegister_12] = 0x30|(LCD->RAM[LCD_RAMRegister_12]); break; } case 8: { //显示个位8 // LCD_WriteRAM(LCD_RAMRegister_2,0X02); assert_param(IS_LCD_RAM_REGISTER(LCD_RAMRegister_2)); LCD->RAM[LCD_RAMRegister_2] = 0x02|(LCD->RAM[LCD_RAMRegister_2]); // LCD_WriteRAM(LCD_RAMRegister_5,0X30); assert_param(IS_LCD_RAM_REGISTER(LCD_RAMRegister_5)); LCD->RAM[LCD_RAMRegister_5] = 0x30|(LCD->RAM[LCD_RAMRegister_5]); // LCD_WriteRAM(LCD_RAMRegister_9,0X03); assert_param(IS_LCD_RAM_REGISTER(LCD_RAMRegister_9)); LCD->RAM[LCD_RAMRegister_9] = 0x03|(LCD->RAM[LCD_RAMRegister_9]); // LCD_WriteRAM(LCD_RAMRegister_12,0X30); assert_param(IS_LCD_RAM_REGISTER(LCD_RAMRegister_12)); LCD->RAM[LCD_RAMRegister_12] = 0x30|(LCD->RAM[LCD_RAMRegister_12]); break; } case 9: { //显示个位9 // LCD_WriteRAM(LCD_RAMRegister_2,0X02); assert_param(IS_LCD_RAM_REGISTER(LCD_RAMRegister_2)); LCD->RAM[LCD_RAMRegister_2] = 0x02|(LCD->RAM[LCD_RAMRegister_2]); // LCD_WriteRAM(LCD_RAMRegister_5,0X10); assert_param(IS_LCD_RAM_REGISTER(LCD_RAMRegister_5)); LCD->RAM[LCD_RAMRegister_5] = 0x10|(LCD->RAM[LCD_RAMRegister_5]); // LCD_WriteRAM(LCD_RAMRegister_9,0X03); assert_param(IS_LCD_RAM_REGISTER(LCD_RAMRegister_9)); LCD->RAM[LCD_RAMRegister_9] = 0x03|(LCD->RAM[LCD_RAMRegister_9]); // LCD_WriteRAM(LCD_RAMRegister_12,0X30); assert_param(IS_LCD_RAM_REGISTER(LCD_RAMRegister_12)); LCD->RAM[LCD_RAMRegister_12] = 0x30|(LCD->RAM[LCD_RAMRegister_12]); break; } } //**********************************************************////// delay(500); //**********************************************************////// //***************************清屏***************************////// LCD_WriteRAM(LCD_RAMRegister_2,0X00); LCD_WriteRAM(LCD_RAMRegister_5,0X00); LCD_WriteRAM(LCD_RAMRegister_9,0X00); LCD_WriteRAM(LCD_RAMRegister_12,0X00); //**********************************************************////// } //////*********************************延时函数*********************************////// void delay(unsigned int time) {unsigned int i,j; for(i=0;i<255;i++) for(j=time;j>0;j--); } |
STM8S003红外发送
[调查]STM8 STM32新社区首页带给你的感受是:
STM8L15x 低功耗运行模式疑问
STM8S005K6,SPI问题
STM8S103F3P 与STM8S103F3U 区别?
求STM8S105 看门狗程序?
STM32或者STM8有哪些系列带有运算放大器
MSP430可以用STM32( STM8 )替代吗 ?
ST7是什么芯片?跟STM32 STM8有什么区别吗?网上资料也不多
STM8L 进入halt()模式,IWDG,停止后仍然复位
显示个位0
// LCD_WriteRAM(LCD_RAMRegister_2,0X02);
assert_param(IS_LCD_RAM_REGISTER(LCD_RAMRegister_2));
LCD->RAM[LCD_RAMRegister_2] = 0x02|(LCD->RAM[LCD_RAMRegister_2]); 大哥你知道这三句什么意思啊,还有为什么显示0是赋值0x02?谢谢给我说下