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

          新聞中心

          EEPW首頁 > 嵌入式系統(tǒng) > 設計應用 > XS128單片機實驗:諾基亞5110液晶顯示

          XS128單片機實驗:諾基亞5110液晶顯示

          作者: 時間:2016-12-01 來源:網(wǎng)絡 收藏
          /*********包含的頭文件*****************************/
          #include /* common defines and macros */
          #include "derivative.h" /* derivative-specific definitions */
          #include "WQ.h"
          #include "Font6_8.h"
          #include "Bitmap.h"
          #include "Font16_16.h"
          #include "Font8_16.h"
          /****************宏定義*****************************/
          #define SCLK PTM_PTM4
          #define SDIN PTM_PTM3
          #define LCD_DC PTM_PTM5
          #define LCD_CE PTM_PTM2
          #define LCD_RES PTM_PTM1
          #define LED PTM_PTM0
          /****************函數(shù)申明***************************/
          void LCD_int(void);
          void LCD_write_byte(uchar dt,uchar command);
          void LCD_write_char(uchar *font);
          void LCD_set_XY(uchar x,uchar y);
          void LCD_clear(void);
          /*1.**************************************************/
          // LCD_write_byte: 使用spi接口寫數(shù)據(jù)到LCD
          // 輸入?yún)?shù):dt 寫入的數(shù)據(jù)
          // 使用I/o口模擬SPI總線通訊發(fā)送一個字節(jié)數(shù)據(jù)到LCD顯示
          // Command : 寫數(shù)據(jù)/命令選擇
          // Data : 2013、4、26
          /***************************************************/
          void LCD_write_byte(uchar dt,uchar command) {
          uchar i;
          LCD_CE=0; //使能LCD
          delay_us(40); //延時30us;
          if(command==0) //判斷發(fā)送數(shù)據(jù)還是發(fā)送命令
          LCD_DC=0;
          else
          LCD_DC=1;
          delay_us(40); //延時30us;


          for(i=0;i<8;i++){
          if(dt&0x80)
          SDIN=1; // 發(fā)送高位
          else
          SDIN=0;
          delay_us(40); //延時30us;
          SCLK=0;
          dt=dt<<1;
          SCLK=1;
          }
          LCD_CE=1; //關閉LCD
          }
          /*2.*************************************************/
          // 函 數(shù) :LCD_set_xy
          // 功 能 :設置LCD坐標函數(shù)
          // 說 明 :x:橫坐標 Y縱坐標
          // Date: 2013/4/26
          /*************************************************/
          void LCD_set_XY(uchar x,uchar y){
          LCD_write_byte(0x40|y,0); //列 按位或設置y坐標
          LCD_write_byte(0x80|x,0); //行 按位或 設置x坐標
          }
          /*3.********************************************/
          // LCD_write_char() ;顯示英文字符
          // 輸入?yún)?shù):C :顯示的字符
          // Date: 2013/4/26
          /********************************************/
          void LCD_write_char (uchar *font) {
          uint i;
          for(i=0;i<6;i++)
          LCD_write_byte(font[i],1);

          }
          /*4.*********************************************/
          //函數(shù):LCD_clear
          // 功能:清屏
          // 參數(shù):無
          // Date:2013/4/26
          /************************************************/
          void LCD_clear(void) {
          uint i;
          LCD_write_byte(0x0c,0);
          LCD_write_byte(0x80,0);
          for(i=0;i<504;i++) {
          LCD_write_byte(0,1);
          }
          }
          /*************************************************/
          // LCD_init: LCD初始化
          // 輸入?yún)?shù)無
          // Date :2013、4、26
          /************************************************/
          void LCD_int(void) {
          LCD_RES=0;
          delay_ms(2);
          LCD_RES=1;
          LCD_write_byte(0x21,0);//初始化LCD,功能設定使用擴充指令
          LCD_write_byte(0xd0,0);//設定液晶偏置電壓;
          LCD_write_byte(0x20,0);//使用基本指令
          LCD_write_byte(0x0c,0);//設定顯示模式,正常顯示
          }

          /****************************************************/
          // 主函數(shù):void mian
          // 功 能:在諾基亞5110液晶屏上顯示字符
          // 作 者:wangqi
          // 時 間;2013、4、26
          /****************************************************/
          void main(){
          unsigned char A[6]={0x00,0x7c,0x12,0x11,0x12,0x7c};
          unsigned char B[6]={0x00,0x7f,0x49,0x49,0x49,0x36};
          DDRM = 0xFF;
          LCD_int();
          LCD_clear();
          LED=1;
          delay_s(5);
          LED=0;
          while(1){

          LCD_set_XY(0,1);
          LCD_write_char(A);
          delay_ms(100);
          LCD_set_XY(10,1);
          LCD_write_char(A);
          delay_ms(100);
          LCD_set_XY(0,3);
          LCD_write_char(B);
          delay_ms(100);
          LCD_set_XY(10,4) ;
          LCD_write_char(B);
          }
          }


          評論


          技術專區(qū)

          關閉
          看屁屁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); })();