[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[avr-gcc-list] Problem to control S1D13305 (SED1335-Epson Controller) wi
From: |
Sach |
Subject: |
[avr-gcc-list] Problem to control S1D13305 (SED1335-Epson Controller) with using ATmega32 |
Date: |
Fri, 4 Jul 2008 04:00:44 -0700 (PDT) |
hi,
I am trying to control S1D13305 (SED1335-Epson Controller) based Graphic LCD
with using AVR ATmega32 microcontroller.
I have written the demo code in c language for it in AVRStudio4. The problem
is i am not getting any output on LCD. I have read the datasheet of SED1335
many times but i can not understand in details how to initialize LCD, about
delay of LCD, contrast port values etc.
Please help me with this.
Regards,
Sachin Rathod,
India.
My code looks like this:
#include <avr/io.h>
void IOInit(void);
void LcdInit(void);
void SendLcdCommand(unsigned char Command);
void SendLcdData(unsigned char Data);
void Delay(unsigned int counter);
void ClearText(void);
void ClearGraphics(void);
void InstructionSet(void);
#define DataPort PORTC
#define CtrlPort PORTD
#define DataDDR DDRC
#define CtrlDDR DDRD
#define RD (1<<PD0)
#define WR (1<<PD1)
#define A0 (1<<PD2)
#define CS (1<<PD3)
#define RST (1<<PD4)
#define FS1 (1<<PD5)
#define SystemSet 0x40
#define SleepIn 0x53
#define DispOff 0x58
#define DispOn 0x59
#define Scroll 0x44
#define CurForm 0x5D
#define CGRAMAddr 0x5C
#define CurRight 0x4C
#define CurLeft 0x4D
#define CurUp 0x4E
#define CurDown 0x4F
#define HdotScr 0x5A
#define Overlay 0x5B
#define SetCurAddr 0x46
#define ReadCurAddr 0x47
#define MemWrite 0x42
#define MemRead 0x43
unsigned int i = 1000;
int main(void)
{
IOInit();
Delay(i);
LcdInit();
InstructionSet();
SendLcdCommand(SetCurAddr);
SendLcdData(0x00);
SendLcdData(0x00);
SendLcdCommand(CurRight);
SendLcdCommand(MemWrite);
for (i = 0; i<= 39; i++)
{
SendLcdData('A');
}
while(1);
}
void IOInit(void)
{
DataDDR = 0xFF;
CtrlDDR = (RD|WR|A0|CS|RST|FS1);
}
void LcdInit(void)
{
CtrlPort |= (RD|WR);
CtrlPort &= (~CS)|(~RST)|(~FS1);
Delay(i);
CtrlPort |= RST;
}
void SendLcdCommand(unsigned char Command)
{
CtrlPort |= A0;
DataPort = Command;
CtrlPort &= (~WR);
Delay(i);
CtrlPort |= WR;
}
void SendLcdData(unsigned char Data)
{
CtrlPort &= (~A0);
DataPort = Data;
CtrlPort &= (~WR);
Delay(i);
CtrlPort |= WR;
}
void Delay(unsigned int counter)
{
while(counter)
{
counter = counter - 1;
}
}
void ClearText(void)
{
SendLcdCommand(SetCurAddr);
SendLcdData(0x00);
SendLcdData(0x00);
SendLcdCommand(CurRight);
SendLcdCommand(MemWrite);
for(i = 0; i <= 1200; i++)
{
SendLcdData(0x20);
}
}
void ClearGraphics(void)
{
SendLcdCommand(SetCurAddr);
SendLcdData(0x00);
SendLcdData(0x10);
SendLcdCommand(CurRight);
SendLcdCommand(MemWrite);
for(i = 0; i <= 9600; i++)
{
SendLcdData(0x00);
}
}
void InstructionSet(void)
{
SendLcdCommand(SystemSet);
SendLcdData(0x32);
SendLcdData(0x87);
SendLcdData(0x07);
SendLcdData(0x27);
SendLcdData(0x2B);
SendLcdData(0xEF);
SendLcdData(0x28);
SendLcdData(0x00);
SendLcdCommand(Scroll);
SendLcdData(0x00);
SendLcdData(0x00);
SendLcdData(0xEF);
SendLcdData(0x00);
SendLcdData(0x10);
SendLcdData(0xEF);
SendLcdCommand(Overlay);
SendLcdData(0x01);
SendLcdCommand(DispOff);
SendLcdData(0x00);
ClearText();
ClearGraphics();
SendLcdCommand(DispOn);
SendLcdData(0x14);
SendLcdCommand(SetCurAddr);
SendLcdData(0x00);
SendLcdData(0x00);
SendLcdCommand(CurForm);
SendLcdData(0x04);
SendLcdData(0x86);
}
--
View this message in context:
http://www.nabble.com/Problem-to-control-S1D13305-%28SED1335-Epson-Controller%29-with-using-ATmega32-tp18277345p18277345.html
Sent from the AVR - gcc mailing list archive at Nabble.com.
- [avr-gcc-list] Problem to control S1D13305 (SED1335-Epson Controller) with using ATmega32,
Sach <=