Hello, im using a powertip 320x240 lcd module, which uses the sed1335
controler. im also using an Atmel uc, the ATmega8515.
I was wondering if anybody has used this controler with this uc, or
not, but i would apreciate any code examples for the initialization
routine.
I wrote a quick hack to test this display. You are welcome to look at
it and adapt it to your application.
and another question, how can i find out if the lcd module is
"Single-Panel Drive" or "Double-Panel Drive" ? the module is:
PG320240FRS-DE4-H-A1
It's single panel drive.
--
John Devereux
----------------------------------------------------------------------
----------------------------------------------------------------------
..
..
..
/* 1/4 VGA with SED1335 controller - test program */
/* avr specific definitions */
#define CTL PORTC
#define CTL_DDR DDRC
#define DATA PORTA
#define DATA_IN PINA
#define DATA_DDR DDRA
/* connections to control port - all "normally high" */
#define RD 0 /* active low read strobe */
#define WR 1 /* active low write strobe */
#define A0 2 /* selects command/data */
#define CS 3 /* active low lcd chip select strobe */
#define RES 4 /* active low reset strobe */
/* SED1335 specific definitions */
#define CMD_SYSTEM 0x40
#define CMD_SLEEP 0x53
#define CMD_SCROLL 0x44
#define CMD_CSRFORM 0x5d
#define HDOTS 320
#define VDOTS 240
#define SX (HDOTS/8)
#define START (0x2000)
/* write data byte (A0 low) */
inline static void wr_data(uint8_t x)
{
DATA = x;
CTL &= ~(1<<A0 | 1<<CS | 1<<WR);
CTL |= (1<<A0 | 1<<CS | 1<<WR);
}
/* write control byte (A0 high) */
inline static void wr_ctl(uint8_t x)
{
DATA = x;
CTL &= ~(1<<CS | 1<<WR);
CTL |= (1<<CS | 1<<WR);
}
/* read data byte (A0 high) */
static uint8_t rd(void)
{
uint8_t x;
DATA_DDR=0;
CTL &= ~(1<<CS | 1<<RD);
asm("nop");
asm("nop");
x = inp(PINA);
CTL |= (1<<CS | 1<<RD);
DATA_DDR=0xff;
return x;
}
/* read status byte (A0 low) */
static uint8_t rd_ctl(void)
{
uint8_t x;
DATA_DDR=0;
CTL &= ~(1 << A0 | 1<<CS | 1<<RD);
asm("nop");
x = inp(PINA);
asm("nop");
CTL |= (1<<A0 | 1<<CS | 1<<RD);
DATA_DDR=0xff;
return x;
}
/* set cursor address */
inline static void set_address(unsigned int address)
{
wr_ctl(0x46);
wr_data(address % 0x100);
wr_data(address / 0x100);
}
void lcd_wr(uint8_t *src, unsigned dst, int len)
{
set_address(dst);
wr_ctl(0x42);
while(len--)
{
DATA = *src++;
CTL &= ~(1<<A0 | 1<<CS | 1<<WR);
CTL |= (1<<A0 | 1<<CS | 1<<WR);
}
}
void lcd_rd(unsigned src, uint8_t *dst, int len)
{
set_address(src);
wr_ctl(0x43);
DATA_DDR=0;
while(len--)
{
CTL &= ~(1<<CS | 1<<RD);
asm("nop");
asm("nop");
*dst++ = inp(PINA);
CTL |= (1<<CS | 1<<RD);
}
DATA_DDR=0xff;
}
void lcd_clr(void)
{
int len=32768;
set_address(START);
wr_ctl(0x42);
while(len--)
{
DATA = 0;
CTL &= ~(1<<A0 | 1<<CS | 1<<WR);
CTL |= (1<<A0 | 1<<CS | 1<<WR);
}
}
/* initialise display */
void lcd_init(void)
{
wr_ctl(CMD_SYSTEM);
wr_data(0x30); /* single panel, IV set */
wr_data(0x07); /* FX, WF 8 colummn chars, WF flag set */
wr_data(0x07); /* FY8 row characters */
wr_data(39); /* C/R roughly, "chars/row" */
wr_data(39+4); /* TC/R "Total chars/row" including blanking*/
wr_data(239); /* L/F "lines per frame?" */
wr_data(40); /* APL "Address Pitch (Low)" (of "virtual" screen) */
wr_data(0); /* APH */
/* display on */
wr_ctl(0x59);
/* no cursor, turn on first screen block (only), no flashing */
wr_data(0x04);
/* SCROLL command (setup regions) */
wr_ctl(0x44);
/* SAD1L,SAD1H,SL1 region 0 address start at 0x0000*/
wr_data(START%0xff);
wr_data(START/0x100);
wr_data(240);
/* SAD2L, SAD2H, SL2 */
wr_data(0);
wr_data(0);
wr_data(240);
/* SAD3L, SAD3H */
wr_data(0);
wr_data(0);
/* 16x16 block cursor */
wr_ctl(CMD_CSRFORM);
wr_data(0x1);
wr_data(0x81);
/* set cursor address */
set_address(START);
/* cursor direction: forward */
wr_ctl(0x4c);
/* select overlay config */
wr_ctl(0x5b);
/* select graphics mode for screens 1 and 3*/
wr_data(0x0c);
lcd_clr();
/* cursor off */
wr_ctl(0x59);
/* no cursor, turn on first screen block only, no flashing */
wr_data(0x04);
}
int main(void)
{
unsigned i;
XP_TRACE_PORT=0;
XP_TRACE_DDR=0xff;
osHardwareInit();
DATA_DDR = 0xff;
/* control signals are all "normally high" */
CTL |= 1<<RD | 1<<WR | 1<<A0 | 1<<CS | 1<<RES;
CTL_DDR = 1<<RD | 1<<WR | 1<<A0 | 1<<CS | 1<<RES;
/* pulse reset low for 100ms */
CTL &= ~(1<<RES);
osDelayms(2);
CTL |= (1<<RES);
osDelayms(4);
lcd_init();
/* displays a letter "A" */
uint8_t A[]=
{
0x10,0x10,0x28,0x28,0x44,0x7c,0x82,0x82
};
set_address(START);
wr_ctl(0x42);
for(i=0;i<40*240;i++)
{
if(i%40 == 10 && (i/40)>7 && (i/40)<16)
wr_data(A[(i/40)%8]);
else wr_data(0);
}
for(;
osTraceToggle(1);
}