Problem to control S1D13305 (SED1335-Epson Controller) with using ATmega32

View: New views
4 Messages — Rating Filter:   Alert me  

Problem to control S1D13305 (SED1335-Epson Controller) with using ATmega32

by SachinRathod :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

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);
}
SachinRathod

Re: Problem to control S1D13305 (SED1335-Epson Controller) with using ATmega32

by Paulo Marques :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Sach wrote:

> hi,
>
> I am trying to control S1D13305 (SED1335-Epson Controller) based Graphic LCD
> with using AVR ATmega32 microcontroller.
> [...]
>
> void Delay(unsigned int counter)
> {
> while(counter)
> {
> counter = counter - 1;
> }
> }

I didn't check the whole code, but at least this part is bad as the
compiler is free to optimize this function away completely.

Place a:

#define F_CPU  8000000UL

on the top of your code and use the delay macros in "util/delay.h".

I hope this helps,

--
Paulo Marques
Software Development Department - Grupo PIE, S.A.
Phone: +351 252 290600, Fax: +351 252 290601
Web: www.grupopie.com


_______________________________________________
AVR-GCC-list mailing list
AVR-GCC-list@...
http://lists.nongnu.org/mailman/listinfo/avr-gcc-list

Re: Problem to control S1D13305 (SED1335-Epson Controller) with using ATmega32

by Preston Wilson :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

"Paulo Marques" wrote:

> Sach wrote:
>> hi,
>>
>> I am trying to control S1D13305 (SED1335-Epson Controller) based Graphic LCD
>> with using AVR ATmega32 microcontroller.
>> [...]
>>
>> void Delay(unsigned int counter)
>> {
>> while(counter)
>> {
>> counter = counter - 1;
>> }
>> }
>
> I didn't check the whole code, but at least this part is bad as the
> compiler is free to optimize this function away completely.
>
> Place a:
>
> #define F_CPU  8000000UL
>
> on the top of your code and use the delay macros in "util/delay.h".
>
> I hope this helps,

The overuse of the global variable "i" is at least part of the problem.

-Preston




_______________________________________________
AVR-GCC-list mailing list
AVR-GCC-list@...
http://lists.nongnu.org/mailman/listinfo/avr-gcc-list

Re: Problem to control S1D13305 (SED1335-Epson Controller) with using ATmega32

by Blake Leverett :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hello Sach,

I don't know much about the SED1335, but I can give some advice.  See my
comments below.

Blake

On Friday 04 July 2008, Sach wrote:

> 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.
>
<snip>

> void LcdInit(void)
> {
> CtrlPort |= (RD|WR);
> CtrlPort &= (~CS)|(~RST)|(~FS1);
This won't work. It should be
        CtrlPort &= ~(CS|RST|FS1);
> Delay(i);
> CtrlPort |= RST;
> }
<snip>

This Delay() funtion will be entirely optimized out, and won't even get
called.  You can fix it by using a volatile counter as shown below, or use
the avr-libc's delay() function, which is better.
> void Delay(unsigned int counter)
> {
        volatile cnt = counter;
        // change counter to cnt below:
> while(counter)
> {
> counter = counter - 1;
> }
> }


_______________________________________________
AVR-GCC-list mailing list
AVR-GCC-list@...
http://lists.nongnu.org/mailman/listinfo/avr-gcc-list
LightInTheBox - Buy quality products at wholesale price