Jump to content
ELFORUM - Forumul electronistilor

Citire date din LCD


Guest MirceaMurar

Recommended Posts

Guest MirceaMurar

Salut!

Am intampinat o problema la citirea din memoria DDRAM a LCD-ului, va rog daca se poate sa ma ajutati

Lucru la un proiect in care folosesc un LCD 4x20 si un Atmega16.

In mare problema este urmatoarea: am un sir de caractere pe prima linie a LCD-ului, acest sir eu trebuie sa-l scriu si pe linia 2.

Am pus si codul scris, in cazul in care nu intelegeti undeva ce am vrut sa fac, va rog sa ma intrebati

 

:sparge:

 

#define F_CPU 1000000UL#include <avr/io.h>#include <util/delay.h>#include <string.h>void PortsSet();void Write( char s[] );void GetChar();int first_line = 0x80; // adress of the first line of LCDint second_line = 0xC0; // second line adresschar ddram_info = 0x00;	int main(){	PortsSet();	Write("ABCDEFG");	// vreau sa citesc primele 4 caractere	while( first_line <= 0x83 )	{		GetChar();		first_line++; // next column of first line	}	return 0;}void PortsSet(){	PORTC = 0x00;	DDRC = 0xFF; 	// PORTC pins are connected to D0....D7 LCD Data pins	PORTD = 0x00;	DDRD |= ( ( 1 << PD0 ) | ( 1 << PD1 ) | ( 1 << PD2 ));	// PD0 is connected to E pin , Enable 	// PD1 is connected to R/W pin, Read/Write	// PD2 is connected to RS pin, Register Select		// second LCD line set	PORTD |= ( 1 << PD0 );	PORTC = 0x38;	PORTD &= ~( 1 << PD0 );	_delay_ms( 10 );	// Cursor ON, Blinling ON	PORTD = 0x01;	PORTC = 0x0F;	PORTD = 0x00;	_delay_ms( 10 );}void Write( char s[] ){	short int i = 0;	for ( i = 0; i < strlen( s) ; i++ )	{		PORTD |= ( ( 1 << PD0 ) | ( 1 << PD2 ) );		PORTC = s[i];		PORTD &=  ~( 1 << PD0 );		_delay_ms( 5 );	}}void GetChar(){	PORTD = 0x00;		// setting the DDRAM adress at the beggining of the first LCD line, column 0;		PORTD |= ( 1 << PD0 );	PORTC = first_line;	PORTD &= ~( 1 << PD0 );	_delay_ms( 10 );	// I assumed that in order to receive information I have to set PORTC pins as input	DDRC = 0x00;	_delay_ms( 100 );	//reading the information from DDRAM	PORTD |= ((1<<PD2)|(1<<PD1)|(1<<PD0));	ddram_info = PINC;	_delay_ms( 100 );	PORTD &= ~(1<<PD0);	_delay_ms( 1000 );	// setting the portC as output	DDRC = 0xFF;	_delay_ms( 1000 );		PORTD &= ~(1<<PD1);	//writing the info readed from ddram from the specified adress,	//writing into the second line	PORTD = 0x00;	PORTC = 0x00;	_delay_ms( 1000 );	//moving the cursor at the beggining of the second line, column 0	PORTD |= ( 1 << PD0 );	PORTC = second_line++;	PORTD &= ~( 1 << PD0 );	_delay_ms( 100 );	// writing the info	PORTD |= (( 1 << PD0 ) | ( 1 << PD2 ) );	PORTC = ddram_info;	PORTD &= ~( 1 << PD0 );	_delay_ms( 1000 );}
Link to comment
Share on other sites

Guest MirceaMurar

Mersi mult!Am inlocuit asa cum mi-ai spus si a functionat.Am fost incercat si eu ceva asemanator dar tot fara rezultat.Multumesc inca odata!

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.Terms of Use si Guidelines