| Author |
Message |
|
|
Posted: Feb 11, 2012 - 05:52 PM |
|


Joined: Dec 24, 2011
Posts: 14
Location: San Miniato Pisa Italy
|
|
Hi!
I tried using a display seiko l2014 (using a ks0076), I wrote this little code following the instructions of datsheet ... The code initializes the display software (init()) and sends a character to the display (send()).
I connected pins DB7-DB0 to PortA PA0-PA7, pin E to PortC PC4, pin RS to PC0 and R/W to ground (logical 0)
But the display does not display anything
I use a Stk500 with an atmega32a
Code:
#include <avr/io.h>
#include <stdio.h>
#define F_CPU 4000000UL
#include <util/delay.h>
#define lcd_data PORTA
#define lcd_rs 0
#define lcd_e 4
void e_toggle(void);
void data_send_sel(void);
void comm_send_sel(void);
void write_byte(uint8_t d);
void iniz(void);
void send(void);
void e_toggle(void)
{
PORTC |= (1<<lcd_e); // e=1
_delay_us(50);
PORTC &= ~(1<<lcd_e); // e=0
_delay_us(50);
}
void data_send_sel(void)
{
PORTC |= (1<<lcd_rs); // rs=1
_delay_us(50);
}
void comm_send_sel(void)
{
PORTC &= ~(1<<lcd_rs); // rs=0
_delay_us(50);
}
void write_byte(uint8_t d)
{
lcd_data = d;
e_toggle();
}
void iniz(void)
{
comm_send_sel();
write_byte(0b00110000);
_delay_ms(5);
write_byte(0b00110000);
_delay_us(120);
write_byte(0b00110000);
_delay_us(50);
write_byte(0b00111000);
_delay_us(50);
write_byte(0b00001000);
_delay_us(50);
write_byte(0b00000001);
_delay_us(50);
write_byte(0b00000111);
_delay_us(50);
}
void send(void)
{
comm_send_sel();
write_byte(0b00111000);
_delay_us(50);
write_byte(0b00001110);
_delay_us(50);
write_byte(0b00000110);
_delay_us(50);
data_send_sel();
write_byte(0b01001100);
_delay_us(50);
}
int main()
{
//gestione display seiko 20x4
DDRA = 0xFF; //porta connessa ai pin dati
DDRC = 0xFF; //porta connessa ai pin di gestione
DDRB = 0xFF;
DDRD = 0x00;
PORTB = 0xFE;
while (PIND != 0xFE);
iniz();
PORTB = 0xFD;
while (PIND != 0xFD);
send();
}
I ask you where you think I'm wrong, and possibly how to correct the error ....
ah I've tried in the forum archive, but I have not found anything that contradicts the code I wrote, or that could help me
Bye
Def89 |
|
|
| |
|
|
|
|
|
Posted: Feb 11, 2012 - 06:30 PM |
|


Joined: Sep 04, 2002
Posts: 21257
Location: Orlando Florida
|
|
| Dont you need something like lcdsend("HELLO") in there somewhere? |
_________________ Imagecraft compiler user
|
| |
|
|
|
|
|
Posted: Feb 11, 2012 - 06:56 PM |
|


Joined: Dec 24, 2011
Posts: 14
Location: San Miniato Pisa Italy
|
|
|
Code:
void send(void)
{
comm_send_sel();
write_byte(0b00111000);
_delay_us(50);
write_byte(0b00001110);
_delay_us(50);
write_byte(0b00000110);
_delay_us(50);
data_send_sel();
write_byte(0b01001100);
_delay_us(50);
}
function send () sends a code ascii (0b01001100 = "L") to display, or at least should be, but that does not appear
Bye |
|
|
| |
|
|
|
|
|
Posted: Feb 11, 2012 - 07:08 PM |
|


Joined: Jul 23, 2001
Posts: 2438
Location: Osnabrueck, Germany
|
|
|
Quote:
I use a Stk500 with an atmega32a
JTAG disabled? |
_________________ Stefan Ernst
|
| |
|
|
|
|
|
Posted: Feb 11, 2012 - 08:00 PM |
|


Joined: Dec 24, 2011
Posts: 14
Location: San Miniato Pisa Italy
|
|
|
sternst wrote:
JTAG disabled?
Yes, jtag is disabled by JTAGEN fuse, but why? I haven't any problems to programm the atmega32
I tried to control a HD44780 display but this shows no signs of life
I think the problem is in software, but I do not know where ...
I'm not 100% sure that the displays are working, are recovered from surplus equipment, but it seems strange that neither of them works: (
Bye |
|
|
| |
|
|
|
|
|
Posted: Feb 11, 2012 - 08:32 PM |
|


Joined: Jul 18, 2005
Posts: 62281
Location: (using avr-gcc in) Finchingfield, Essex, England
|
|
|
Quote:
Yes, jtag is disabled by JTAGEN fuse, but why? I haven't any problems to programm the atmega32
You can't use PC4..PC7 if JTAG is hogging those pins |
_________________
|
| |
|
|
|
|
|
Posted: Feb 11, 2012 - 08:40 PM |
|

Joined: Mar 29, 2006
Posts: 567
Location: Western New York, USA
|
|
Take a look at the note that follows the information concerning the 'Function Set' instruction. This is located a few pages after Table 6.
Quote:
Note: Perform the function at the head of the program before executing any instructions (except for the read busy flag and address instruction). From this point, the function set instruction cannot be executed unless the interface data length is changed.
I interpret this as saying that you can only use this instruction once, when you initialize the LCD controller. (I am not including the three instances at the very beginning that actually seem to perform a 'reset').
You have included this instruction both in your iniz and in your send routines.
You should consider adding some more comments to your code to make your intentions clearer to us troubleshooters.
Don |
|
|
| |
|
|
|
|
|
Posted: Feb 11, 2012 - 09:10 PM |
|


Joined: Mar 27, 2002
Posts: 18545
Location: Lund, Sweden
|
|
If we got a € for everyone that has posted here not getting their character LCD display to work we'd have a small fortune by now. There should be enough with ready-to-run implementations to get out of all those discussions.
I am not very interested in fault-seeking your code. Such endeavours almost always demands that one drags out ones own display, wire it up to match the code in question, and then start debugging. In your case it also involves reverse-engineering your binary constants - the C language supports symbolic constants quite well.
My suggestion is that you start with some well tested code that someone else wrote, and then start to alter it to your needs. There are several CLCD libraries available. A search here should give several. Good words to include in your search terms are the respective authors: "Pascal Stang", "Peter Fleury" and "danni" (AVR freaks member Peter Dannegger). If you want some minimal test code, then let me shamelessly promote my own minimal demo here.
Also, the standard questions apply:
What have you done for contrast control?
Since you have data lines on PORTA (and assuming that PORTA also hosts the ADC inputs, something that I leave for you to double-check), have you connected AVCC / AGND also?
HTH! |
|
|
| |
|
|
|
|
|
Posted: Feb 12, 2012 - 11:28 AM |
|


Joined: Dec 24, 2011
Posts: 14
Location: San Miniato Pisa Italy
|
|
|
JohanEkdahl wrote:
Since you have data lines on PORTA (and assuming that PORTA also hosts the ADC inputs, something that I leave for you to double-check), have you connected AVCC / AGND also?
Yes I've connect display so:
pin 1 GND
pin 2 +5V
pin 3 10k trimmer (adjusted to 3.8V)
pin 4 -> PC0
Pin 5 GND
pin 6 -> PC4
pin 7 -> PA0
.
.
Pin 14 -> PA7
I will not invent any new code, first I want to understand how the display works by using a code ready, then I'll worry about to change according to my needs.
The use of PortA and C is random, when I do not like to use other features of the processor
Bye |
|
|
| |
|
|
|
|
|
Posted: Feb 12, 2012 - 12:33 PM |
|


Joined: Jul 18, 2005
Posts: 62281
Location: (using avr-gcc in) Finchingfield, Essex, England
|
|
|
Quote:
pin 3 10k trimmer (adjusted to 3.8V)
It should be about 0.1V - wind it to the other end of the scale. |
_________________
|
| |
|
|
|
|
|
Posted: Feb 12, 2012 - 03:54 PM |
|


Joined: Dec 24, 2011
Posts: 14
Location: San Miniato Pisa Italy
|
|
I tried using the program linked to JohanEkdahl, but even so the display does not work
the value of VLC (pin 3) is set to 0.6V
The manual reports that Vdd - Vlc = 4.4V so Vlc = 0.6V
I do not know what else to try to do: (
Ah ATmega32 F_cpu is 4Mhz
Bye |
|
|
| |
|
|
|
|
|
Posted: Feb 12, 2012 - 05:26 PM |
|


Joined: Mar 27, 2002
Posts: 18545
Location: Lund, Sweden
|
|
| Have you convinced yourself that the AVR is running at all? Have you done the LED blinky? |
|
|
| |
|
|
|
|
|
Posted: Feb 12, 2012 - 06:00 PM |
|


Joined: Dec 24, 2011
Posts: 14
Location: San Miniato Pisa Italy
|
|
|
JohanEkdahl wrote:
Have you convinced yourself that the AVR is running at all? Have you done the LED blinky?
if I understand what you asked me, my English has some gaps ......
Yes I'm sure it will have functions and that the program performs what is written, I have modified your code so I can run "a line of code" only when I push a button, so i can see if on pins 0-7 are the correct codes, displaying them using 7 LEDs, and the codes are correct ....
I ask if you performed the special connections between display and microprocessor, I have directly connected the data pin, the control pins, the power pin and installing only the trimmer for Vlc (between Vcc and Gnd)
I want to thank you for the help that you are giving me, you are great people
Bye |
|
|
| |
|
|
|
|
|
Posted: Feb 12, 2012 - 06:23 PM |
|


Joined: Mar 27, 2002
Posts: 18545
Location: Lund, Sweden
|
|
I was asking if the AVR was running at all, i.e. has a valid CPU clock. My question is void since
You wrote:
I have modified your code so I can run "a line of code" only when I push a button, so i can see if on pins 0-7 are the correct codes, displaying them using 7 LEDs, and the codes are correct ....
which prooves beyond any doubt that it is actually running.
The quote also shows that you actually know what you are doing, and have a high technical skill level. Not everyone manages to implement his own step-debugger in software with a few LEDs. Congratulations!
Can you verify that you see the correct signals on the E (Enable), RS (RegisterSelect) and R/W (Read/Write, if you use it) lines lines also?
Would it be possible to get a photo of the wire-up of the display posted here?
Also, there are some rare character LCD displays that require a negative contrast voltage. Can you spot a manufacturer and model somewhere on the display module - or do you have a link to a data sheet? |
|
|
| |
|
|
|
|
|
Posted: Feb 13, 2012 - 10:14 AM |
|


Joined: Dec 24, 2011
Posts: 14
Location: San Miniato Pisa Italy
|
|
|
|
|
|
|