ravi8820
Junior Member level 1
- Joined
- May 24, 2012
- Messages
- 16
- Helped
- 0
- Reputation
- 0
- Reaction score
- 0
- Trophy points
- 1,281
- Activity points
- 1,483
I am trying to display "hello world" on the jhd 162a lcd using
ATMEGA 16A. I am writing the attached code in winavr but on compiling it is giving the error. lcd is connected with the microcontroller in 4 bit mode.
connection diagram is--------------
even the cursor is not displaying on the lcd................
the code is
the error is
Please help .....................
ATMEGA 16A. I am writing the attached code in winavr but on compiling it is giving the error. lcd is connected with the microcontroller in 4 bit mode.
connection diagram is--------------
Code:
PB 7: Data 7
PB 6: Data 6
PB 5: Data 5
PB 4: Data 4
PB 3: N/A
PB 2: Enable
PB 1: R/W
PB 0: Register Select
even the cursor is not displaying on the lcd................
the code is
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 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 #include <avr/io.h> #include <stdlib.h> #include <util/delay.h> #include <stdio.h> //Define functions //========================================================== void io_init(void); //Initializes IO void send_nibble(unsigned char __rs, unsigned char __data); //========================================================== int main (void) { //io_init(); DDRB =0b11101111; PORTB = 0b01111111; delay_ms(10); PORTB = 0b00100010; // xsending command delay_ms(10); PORTB = 0b00000010; delay_ms(10); PORTB = 0b00101000; // xsending command delay_ms(10); PORTB = 0b00001000; delay_ms(10); PORTB = 0b10100100; // xsending data ‘H’ delay_ms(10); PORTB = 0b10000100; delay_ms(10); PORTB = 0b10101000; // sending data delay_ms(10); PORTB = 0b10001000; delay_ms(10); PORTB= 0b10100100; // sending data ‘E’ delay_ms(10); PORTB= 0b10000100; delay_ms(10); PORTB= 0b10100101; // sending data delay_ms(10); PORTB= 0b10000101; delay_ms(10); PORTB= 0b10100100; // sending data ‘L’ delay_ms(10); PORTB= 0b10000100; delay_ms(10); PORTB= 0b10101100; // sending data delay_ms(10); PORTB= 0b10001100; delay_ms(10); PORTB= 0b10100100; // sending data ‘L’ delay_ms(10); PORTB= 0b10000100; delay_ms(10); PORTB= 0b10101100; // sending data delay_ms(10); PORTB= 0b10001100; delay_ms(10); PORTB= 0b10100100; // sending data ‘O’ delay_ms(10); PORTB= 0b10000100; delay_ms(10); PORTB= 0b10101111; // sending data delay_ms(10); PORTB= 0b10001111; delay_ms(10); PORTB= 0b10100010; // sending data ‘SPACE’ delay_ms(10); PORTB= 0b10000010; delay_ms(10); PORTB=0b10100000; // sending data delay_ms(10); PORTB=0b10000000; delay_ms(10); PORTB= 0b10100101; // sending data ‘W’ delay_ms(10); PORTB= 0b10000101; delay_ms(10); PORTB= 0b10100111; // sending data delay_ms(10); PORTB= 0b10000111; delay_ms(10); PORTB= 0b10100100; // sending data ‘O’ delay_ms(10); PORTB= 0b10000100; delay_ms(10); PORTB= 0b10101111; // sending data delay_ms(10); PORTB= 0b10001111; delay_ms(10); PORTB= 0b10100101; // sending data ‘R’ delay_ms(10); PORTB= 0b10000101; delay_ms(10); PORTB= 0b10100010; // sending data delay_ms(10); PORTB= 0b10000010; delay_ms(10); PORTB= 0b10100100; // sending data ‘L’ delay_ms(10); PORTB= 0b10000100; delay_ms(10); PORTB= 0b10101100; // sending data delay_ms(10); PORTB= 0b10001100; delay_ms(10); PORTB= 0b10100100; // sending data ‘D’ delay_ms(10); PORTB= 0b10000100; delay_ms(10); PORTB= 0b10100100; // sending data delay_ms(10); PORTB= 0b10000100; delay_ms(10); return(0); } void io_init (void) { /* PB 7: Data 7 PB 6: Data 6 PB 5: Data 5 PB 4: Data 4 PB 3: N/A PB 2: Enable PB 1: R/W PB 0: Register Select */ DDRB =0b11101111; } void send_nibble(unsigned char __rs, unsigned char __data) { PORTB = (__rs<<4) | __data | 0b00100000; // Set RS & Data. Set EN=High _delay_ms(10); PORTB = (__rs<<4) | __data; // Set RS & Data. Set EN=Low _delay_ms(10);
the error is
Code:
"> "make.exe" all
-------- begin --------
avr-gcc (WinAVR 20100110) 4.3.3
Copyright (C) 2008 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Compiling C: main.c
avr-gcc -c -mmcu=atmega16 -I. -gdwarf-2 -DF_CPU=8000000UL -Os -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums -Wall -Wstrict-prototypes -Wa,-adhlns=./main.lst -std=gnu99 -MMD -MP -MF .dep/main.o.d main.c -o main.o
main.c: In function 'main':
main.c:18: warning: implicit declaration of function 'delay_ms'
main.c: In function 'send_nibble':
main.c:140: error: expected declaration or statement at end of input
make.exe: *** [main.o] Error 1
> Process Exit Code: 2
> Time Taken: 00:01
"
Please help .....................
Last edited by a moderator: