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
}
#include "picsss.h"
#include <pcf8833.c>
void main()
{
setup_adc_ports(NO_ANALOGS);
setup_adc(ADC_OFF);
setup_psp(PSP_DISABLED);
setup_spi(FALSE);
setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1);
setup_timer_1(T1_DISABLED);
setup_timer_2(T2_DISABLED,0,1);
setup_comparator(NC_NC_NC_NC);
setup_vref(FALSE);
set_tris_c(0x00);
output_c(0x00);
delay_ms(1000);
glcd_init(65);
glcd_cls(BLACK);
glcd_line(0,64,128,64,GREEN);
}
Hi all
I finally made my own driver for the pcf8833 controller.
All i have see on the web was or incomplete or dont have work like i want.
I post 3 examples here :
A 3D rotating cube , a mini breakout game , and the good old pong
change the #define from pcf8833.c for set the pin's you use on the CPU.
Enjoy.
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?