Thông báo

Collapse
No announcement yet.

giúp em hiển thị GLCD PCF8833 bằng ARM LPC2148

Collapse
X
 
  • Lọc
  • Giờ
  • Show
Clear All
new posts

  • giúp em hiển thị GLCD PCF8833 bằng ARM LPC2148

    em đang nghiên cứu ARM LPC2148 của philip và sử dụng nó để Display GLCD 132x132 (PCF8833 LCD của nokia 6100).help , em viet code nhng7 ko hiểu nó sai ở chỗ nào ma LCD cua em cahng hien thi mau gi ca.
    Code:
    /****************************************************/
    
    // LPC2148    ----->  GLCD(6100 display PCF8833)
    // MOSI(P0.6) ------>  DATA(pin 3 )
    // SCK(P0.4)  ------>  SCK
    // MISO(P0.5) -------  NC
    // P0.2         ------>  RS
    // P0.7) ------------> CS
    //P0.3--------------->Blink
    
    #include "LPC214x.H"    
    /* pototype  section */                                  // LPC2148 MPU Register
    //define for LCD
    /*****************************************************************************
              Command of LCD NOKIA6100(phillips chipset)
    *****************************************************************************/
    #define NOP       0x00 // nop
    #define SWRESET    0x01 // software reset
    #define BSTROFF    0x02 // booster voltage OFF
    #define BSTRON       0x03 // booster voltage ON
    #define RDDIDIF    0x04 // read display identification
    #define RDDST       0x09 // read display status
    #define SLEEPIN    0x10 // sleep in
    #define SLEEPOUT    0x11 // sleep out
    #define PTLON       0x12 // partial display mode
    #define NORON       0x13 // display normal mode
    #define INVOFF      0x20 // inversion OFF
    #define INVON       0x21 // inversion ON
    #define DALO       0x22 // all pixel OFF
    #define DAL       0x23 // all pixel ON
    #define SETCON       0x25 // write contrast
    #define DISPOFF    0x28 // display OFF
    #define DISPON       0x29 // display ON
    #define CASET       0x2A // column address set
    #define PASET       0x2B // page address set
    #define RAMWR       0x2C // memory write
    #define RGBSET       0x2D // colour set
    #define PTLAR       0x30 // partial area
    #define VSCRDEF    0x33 // vertical scrolling definition
    #define TEOFF       0x34 // test mode
    #define TEON       0x35 // test mode
    #define MADCTL       0x36 // memory access control
    #define SEP       0x37 // vertical scrolling start address
    #define IDMOFF       0x38 // idle mode OFF
    #define IDMON       0x39 // idle mode ON
    #define COLMOD       0x3A // interface pixel format
    #define SETVOP       0xB0 // set Vop
    #define BRS       0xB4 // bottom row swap
    #define TRS       0xB6 // top row swap
    #define DISCTR       0xB9 // display control
    #define DOR       0xBA // data order
    #define TCDFE       0xBD // enable/disable DF temperature compensation
    #define TCVOPE       0xBF // enable/disable Vop temp comp
    #define EC          0xC0 // internal or external oscillator
    #define SETMUL       0xC2 // set multiplication factor
    #define TCVOPAB    0xC3 // set TCVOP slopes A and B
    #define TCVOPCD    0xC4 // set TCVOP slopes c and d
    #define TCDF       0xC5 // set divider frequency
    #define DF8COLOR    0xC6 // set divider frequency 8-color mode
    #define SETBS       0xC7 // set bias system
    #define RDTEMP       0xC8 // temperature read back
    #define NLI       0xC9 // n-line inversion
    #define RDID1       0xDA // read ID1
    #define RDID2       0xDB // read ID2
    #define RDID3       0xDC // read ID3
    //define pin
    #define RS (1<<2)
    #define CS (1<<7)
    #define BL (1<<3)
    #define SDA       (1<<6) //MOSI
    #define CLK       (1<<4) //CLK
    //define program
    //*****************************************************************************
    //          Program definition
    //*****************************************************************************/
    #define CS0 IOCLR0 = CS
    #define CS1 IOSET0 = CS
    #define CLK0 IOCLR0 = CLK
    #define CLK1 IOSET0 = CLK
    #define SDA0 IOCLR0 = SDA
    #define SDA1 IOSET0 = SDA
    #define RESET0 IOCLR0 = RS
    #define RESET1 IOSET0 = RS
    
    /* pototype  section */
    //****************************************************************************
    //          Program prototype
    //****************************************************************************
    void lcd_init(void);
    void spi_init(void);
    void sendData(unsigned char data);
    void sendCMD(unsigned char com);
    void LCD_put_pixel(unsigned char color, unsigned char x, unsigned char y);
    
    void delay_ms(unsigned long int);                  // Delay Time Function
    //main function
    
    int main(void)
    {
    unsigned int i;
    //int
    IODIR0 =  CS|CLK|SDA|RS;
    lcd_init();
    while(1)
    {
    for(i=1;i<131;i++)
    {
    LCD_put_pixel(0xFC,i,50);
    }
    //test code
    }
    }    
    //=============spi int==================
    
    void spi_init(void)
    {
       PINSEL0 |= 0x00001500; // set port0.4-0.6 SPI0
     
     // SPI0 initial function LCD6100
         S0SPCCR = 8;       // SPI0 clk = VPB clk /S0PCCR
                     //  7.5 MHz = 60 MHz /8
     // SPI0 Register control
         S0SPCR = 0x00000924; // 9 bit data
                        // CPHA=0, CPOL=0
                           // MPU master
                          // MSB first   
                         // SPIF interrupts unable
    }
    //=============end function==============
    
                         
    /*****************************************************************************
              LCD initial Function
    *****************************************************************************/
    void lcd_init(void)
    {
    int i = 0;
    
      spi_init();
    
      /*** Hardware Reset LCD ***/
      RESET0;
      delay_ms(10);
      RESET1;
      delay_ms(10);
      /*** Initial state ***/
      CS0;               // cho phep LCD
      sendCMD(SWRESET);    // Software Reset LCD
      delay_ms(10);
     
      sendCMD(SLEEPOUT); // Sleep out
      delay_ms(10);
      //sendCMD(INVON);   //seem to be requires for this controller
     
      sendCMD(COLMOD);   // 8 bit color
      sendData(0x02);
      sendCMD(NORON);    // Normal Display
      sendCMD(MADCTL);    //   memory access control
      sendData(0x40);    // Miror X
    
      sendCMD(SETCON);    // set contrast
      sendData(63);   
      delay_ms(10);
    
      sendCMD(DISPON);    // Display ON
      delay_ms(10);
       
       /*** Set Black Coulour to Backgound ***/
       sendCMD(CASET);   
       sendData(0);
       sendData(131);
       sendCMD(PASET);   
       sendData(1);     
       sendData(131);
       sendCMD(RAMWR);         
       for(i=0;i<(131*131);i++)
       {
          sendData(0);
        }
    }
    
    /*****************************************************************************
              Send command to LCD Function
    *****************************************************************************/
    void sendCMD(unsigned char com)
    {   
           CS0;// chip select enable
         S0SPDR = com & ~0x0100;// For Command MSB "LOW"
         while((S0SPSR & 0x80)!= 0x80){;;}   // Wait SPIF = 1 (SPI Send Complete)
         CS1; //unselect
    }
    
    /*****************************************************************************
              Send Data to LCd function
    *****************************************************************************/
    void sendData(unsigned char data)
    {
      CS0;
      S0SPDR  = data | 0x0100;// For Data MSB must "HIGH"
      while((S0SPSR & 0x80)!= 0x80){;;}   // Wait SPIF = 1 (SPI Send Complete)
      CS1;
    }
    
    /*****************************************************************************
              LCD plot pixel on LCD Function
    *****************************************************************************/
    
    void LCD_put_pixel(unsigned char color, unsigned char x, unsigned char y)
    {
      sendCMD(PASET);   // page start/end ram  = Row
      sendData(y);
      sendData(131);
      sendCMD(CASET);   // column start/end ram = Colum
      sendData(x);     
      sendData(131);
      sendCMD(RAMWR);    // write DATA
      sendData(color);
    }
    /***********************/
    /* Delay Time Function */
    /***********************/
    
    void delay_ms(unsigned long int count1)
    {
    unsigned int i,k;
    k=count1*2600;
      for(i=0;i<k;i++);                     // Loop Decrease Counter   
    }

  • #2
    Bạn cần chắc chắn rằng con LCD của bạn sử dụng chip Philip, hiện nay trên thị trường bán cả 2 loai LCD dùng chíp Philip và Epson, không thể phân biệt loại chip sử dụng bằng màu PCB như các anh Tây khuyên (Màu cam - philip, màu xanh - Epson) mà phải căn cứ vào mặt sau của LCD, nếu trên PCB có 10 pad hàn thì là loại sử dụng chip Philip, nếu ko có là loại dùng chíp Epson.
    PNLab
    Mạch nạp/debug ULink2, Jlink ARM USB
    Mạch nạp AVR, PIC, 8051, MSP430 USB
    Mạch phát triển STM32, ARM9, ARM11
    more...www.pnlabvn.com

    Comment


    • #3
      cám ơn sphinx
      chắc chắn la con của Philip mà ,em đã test thử bằng chưong trinh test GLCD tren máy tính wa cổng LPT.

      bac nào biết cách hiển thị nó chỉ em dzoi ,Gấp gấp lắm ,gần nộp Đồ án rồi

      Comment


      • #4
        http://www.electricstuff.co.uk/noklcd.html
        trang chỉ cách phần biệt LCD 6610

        Comment


        • #5
          bạn có thể cho mình biết bạn o đâu ko vậy, mình cũng dang làm con lpc2148 giao tiếp với LCD 6100 của nokia nè ,email cua mình là: diep_vy@yahoo.com

          Comment

          Về tác giả

          Collapse

          hbaocr Tìm hiểu thêm về hbaocr

          Bài viết mới nhất

          Collapse

          Đang tải...
          X