Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[AVR] Help [16x2 LCD interfacing with atmega16]

Status
Not open for further replies.

pavan.chvs95

Newbie level 2
Newbie level 2
Joined
Jan 2, 2015
Messages
2
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Visit site
Activity points
28
Hi guys,

I am new to this forum as well as to AVRs.Ive recently tried to interface Atmega16 with an LCD display(16x2).I am using PORTD as data port and PORTB for control signals.Clk frequency is selected as 4Mhz(internal).

The code is as follows:

Code C - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#define F_CPU 4000000
#include <avr/io.h>
#include <util/delay.h>
#define MrLCDsCrib PORTD
#define DataDir_MrLCDsCrib DDRD
#define MrLCDsControl PORTB
#define DataDir_MrLCDsControl DDRB
#define LightSwitch 2
#define ReadWrite 1
#define BiPolarMood 0
void Check_IF_MrLCD_isBusy(void);
void Peek_A_Boo(void);
void Send_A_Command(unsigned char command);
void Send_A_Character(unsigned char character);
void Send_A_String(char *StringOfCharacters);
int main(void)
{
    DataDir_MrLCDsControl |= 1<<LightSwitch | 1<<ReadWrite | 1<<BiPolarMood;
    _delay_ms(50);
    Send_A_Command(0x01); //Clear Screen 0x01 = 00000001
    _delay_ms(50);
    Send_A_Command(0x38);
    _delay_us(50);
    Send_A_Command(0b00001110);
    _delay_us(50);
    Send_A_String("Newbie");
    while(1)
    {
    }
}
void Check_IF_MrLCD_isBusy()
{
    DataDir_MrLCDsCrib = 0;
    MrLCDsControl |= 1<<ReadWrite;
    MrLCDsControl &= ~1<<BiPolarMood;
    while (MrLCDsCrib >= 0x80)
    {
        Peek_A_Boo();
    }
    DataDir_MrLCDsCrib = 0xFF; //0xFF means 0b11111111
}
void Peek_A_Boo()
{
    MrLCDsControl |= 1<<LightSwitch;
    asm volatile ("nop");
    asm volatile ("nop");
    MrLCDsControl &= ~1<<LightSwitch;
}
void Send_A_Command(unsigned char command)
{
    Check_IF_MrLCD_isBusy();
    MrLCDsCrib = command;
    MrLCDsControl &= ~ ((1<<ReadWrite)|(1<<BiPolarMood));
    Peek_A_Boo();
    MrLCDsCrib = 0;
}
void Send_A_Character(unsigned char character)
{
    Check_IF_MrLCD_isBusy();
    MrLCDsCrib = character;
    MrLCDsControl &= ~ (1<<ReadWrite);
    MrLCDsControl |= 1<<BiPolarMood;
    Peek_A_Boo();
    MrLCDsCrib = 0;
}
void Send_A_String(char *StringOfCharacters)
{
    while(*StringOfCharacters > 0)
    {
        Send_A_Character(*StringOfCharacters++);
    }
}

Now,the problem is that the output is discontinuous.(For example if i send "Newbie",output is like "N w b e").

Can any one please help me with this problem?:roll:
 
Last edited by a moderator:


Ive tried putting 1ms delay as you said,but no change.

Ive also loaded your program after changing the port configuration in program.But,the output is blank.:-?
 

Check if the routine Check_IF_MrLCD_isBusy() is working properly, taking special attention to logic levels of control pins.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top