Sari la conținut
ELFORUM - Forumul electronistilor

Citire date din LCD


Vizitator MirceaMurar

Postări Recomandate

Vizitator 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 spre comentariu
  • Răspunsuri 2
  • Creat
  • Ultimul Răspuns

Top autori în acest subiect

  • Laci

    1

Top autori în acest subiect

Creează un cont sau autentifică-te pentru a adăuga comentariu

Trebuie să fi un membru pentru a putea lăsa un comentariu.

Creează un cont

Înregistrează-te pentru un nou cont în comunitatea nostră. Este simplu!

Înregistrează un nou cont

Autentificare

Ai deja un cont? Autentifică-te aici.

Autentifică-te acum



×
×
  • Creează nouă...

Informații Importante

Am plasat cookie-uri pe dispozitivul tău pentru a îmbunătății navigarea pe acest site. Poți modifica setările cookie, altfel considerăm că ești de acord să continui.Termeni de Utilizare si Ghidări