<meter id="pryje"><nav id="pryje"><delect id="pryje"></delect></nav></meter>
          <label id="pryje"></label>

          新聞中心

          EEPW首頁 > 嵌入式系統(tǒng) > 設(shè)計應(yīng)用 > 基于MDK編譯器 STM32與12864液晶顯示程序 和電路連接

          基于MDK編譯器 STM32與12864液晶顯示程序 和電路連接

          作者: 時間:2016-11-24 來源:網(wǎng)絡(luò) 收藏
          里附上的是主程序部分和電路連接

          這里用的12864液晶是5v的,電路鏈接部分 RS PE2 RW PE4 EN PE6 15口PSB串并 PE3

          #include "stm32f10x.h"
          GPIO_InitTypeDef GPIO_InitStructure;
          #define RS_SET GPIO_SetBits(GPIOE, GPIO_Pin_2)
          #define RS_CLR GPIO_ResetBits(GPIOE, GPIO_Pin_2)
          #define RW_SET GPIO_SetBits(GPIOE, GPIO_Pin_4)
          #define RW_CLR GPIO_ResetBits(GPIOE, GPIO_Pin_4)
          #define EN_SET GPIO_SetBits(GPIOE, GPIO_Pin_6)
          #define EN_CLR GPIO_ResetBits(GPIOE, GPIO_Pin_6)
          #define PSB_SET GPIO_SetBits(GPIOE, GPIO_Pin_3)
          #define PSB_CLR GPIO_ResetBits(GPIOE, GPIO_Pin_3)
          #define DATA_IO GPIOC->ODR
          void RCC_Configuration(void);
          void LCD12864_Config(void);
          void Delay_nus(__IO uint32_t nCount);
          void Delay_mus(__IO uint32_t nCount);
          uint8_t table[]="做我女朋友吧!";
          void write_12864com(uint8_t com)
          {
          RW_CLR;
          RS_CLR;
          Delay_nus(500);
          DATA_IO=com;
          EN_SET;
          Delay_nus(1000);
          EN_CLR;
          Delay_nus(1000);
          }
          void write_12864dat(uint8_t dat)
          {
          RW_CLR;
          RS_SET;
          Delay_nus(500);
          DATA_IO=dat;
          EN_SET;
          Delay_nus(1000);
          EN_CLR;
          Delay_nus(1000);
          }
          void init12864lcd(void)
          {
          Delay_mus(500);
          write_12864com(0x30);
          Delay_nus(500);
          write_12864com(0x30);
          Delay_nus(500);
          write_12864com(0x0f);
          Delay_nus(500);
          write_12864com(0x01);
          Delay_nus(25);
          write_12864com(0x06);
          Delay_nus(2500);
          write_12864com(0x0c);
          Delay_nus(500);
          }
          void display(void)
          {
          uint8_t i;
          write_12864com(0x80);
          for(i=0;i<14;i++)
          {
          write_12864dat(table[i]);
          Delay_mus(50);
          }
          }
          void LCD12864_Config(void)
          {
          RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOE | RCC_APB2Periph_GPIOC , ENABLE);
          GPIO_InitStructure.GPIO_Pin = GPIO_Pin_2|GPIO_Pin_3|GPIO_Pin_4|GPIO_Pin_6;
          GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
          GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
          GPIO_Init(GPIOE, &GPIO_InitStructure);
          GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0|GPIO_Pin_1|GPIO_Pin_2|GPIO_Pin_3
          |GPIO_Pin_4|GPIO_Pin_5|GPIO_Pin_6|GPIO_Pin_7;
          GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
          GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
          GPIO_Init(GPIOC, &GPIO_InitStructure);
          }
          int main(void)
          {
          RCC_Configuration(); //系統(tǒng)時鐘配置
          LCD12864_Config();
          PSB_SET;
          init12864lcd();
          while (1)
          {
          display();
          }
          }
          void RCC_Configuration(void)
          {
          SystemInit();
          }
          void Delay_nus(uint32_t nCount)
          {
          uint32_t j;
          while(nCount--)
          {
          j=8;
          while(j--);
          }
          }
          void Delay_mus(uint32_t nCount)
          {
          while(nCount--)
          Delay_nus(1100);
          }


          關(guān)鍵詞: MDK編譯器STM3212864液

          評論


          技術(shù)專區(qū)

          關(guān)閉
          看屁屁www成人影院,亚洲人妻成人图片,亚洲精品成人午夜在线,日韩在线 欧美成人 (function(){ var bp = document.createElement('script'); var curProtocol = window.location.protocol.split(':')[0]; if (curProtocol === 'https') { bp.src = 'https://zz.bdstatic.com/linksubmit/push.js'; } else { bp.src = 'http://push.zhanzhang.baidu.com/push.js'; } var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(bp, s); })();