Jump to content
ELFORUM - Forumul Electronistilor
Sign in to follow this  
Guest vaidaionutradu

soft pentru LCD

Recommended Posts

Guest vaidaionutradu

am o mare rugaminte daca ma puteti ajuta ca eu habar nu am la partea cu soft la ce si unde sa ma uit...:) imi trebuie un soft pentru compilator mplab care sa imi afiseye pe un lcd de la un pic18f458 de exemplu "50%" as vrea sa afisez. lcd-ul l-am legat in configuratia ce am atasat-o v-as fi foarte recunoscator daca ma puteti ajuta si poate la nevoi pot sa fac si eu ceva...sau daca nu cine stie sa faca sa imi zica cat face..:Ppinii cred ca stiti cum sunt la lcd:1-gnd2-vcc3-contrast4-rs5-r/w6-e7-...14-DB0...Db715-K16-A

Share this post


Link to post
Share on other sites

In primul rand ce fel de lcd ai si de unde l-ai cumparat. Poti sa te uiti pentru detalii pe topicul "interfete si comunicatii".

Share this post


Link to post
Share on other sites
Guest vaidaionutradu

lcd-ul este de tip dem16216sgh cumparat de ma microelectronica cluj ,,,si din cat stiu eu adus de la display electronik.

Share this post


Link to post
Share on other sites
Guest vaidaionutradu

pai nush...in ce e mai usor sa zic asa...ca sa il pot programa cu mplab...de stiut care e diferenta intre c si asm stiu dar nu stiu care ar trebui....cum e mai bine.. eu am incercat un soft da imi aprinde numa o linie neagra cap coada pe lcd si atat nici macar cursor nu am probabil ca am incercat ciu liniile de date legate la db0-db3...si acum am citit in foaia de catalog ca la receptia pe 4 biti se conecteaya la db4-db7 deci cred ca nu conteaya in ce e scris sa il pot programa numai ca programator am...:)

Share this post


Link to post
Share on other sites

Uite aici ceva ASM: http://www.elforum.info/viewtopic.php?t=11293&highlight=lcd+display+lcm1602 care eu l-am adaptat. Cea mai importanta parte este rutina de initializare, fara care nu merge lcd-ul. O modificare fata de varianta de mai sus (asa am vazut in data shet-ul produsului), daca nu merge este sa renunti la RESET 3. Mai trebuie sa introduci functiile DELAY_40, DELAY_5 si DELAY_X.

Share this post


Link to post
Share on other sites

Asa am facut eu in C, folosind portul D:"lcd.h":aici modifica asa cum ai facut tu legaturile hard(RS, RW, E si DB4-DB7):

// fisierul lcd.h#ifndef LCD_H#define LCD_H#ifndef	_PIC_H	#include <pic.h>#endif#ifndef XTAL_FREQ	#include "delay.h"#endif#define LCD_RS RD2     // aici introdu portul tau#define LCD_RW RD1#define LCD_E  RD0#define	LCD_STROBE	(LCD_E = 1);(LCD_E = 0);#define LCD_DB7 RD7#define LCD_DB6 RD6#define LCD_DB5 RD5#define LCD_DB4 RD4void lcd_write(unsigned char c);void lcd_clear(void);void lcd_puts(const char * s);void lcd_putch(char c);void lcd_gotoxy(unsigned char pos, unsigned char line);void lcd_init(void);
si "lcd.c": aici poti sa modifici daca vrei "lcd_write()" si "lcd_putch()" (pentru o executie mai rapida). Deci singura problema daca nu merge este "lcd_init()":
// fisierul  lcd.c#include "lcd.h"void lcd_write(unsigned char c){	LCD_DB7 = (c >> 7) &0x01;	LCD_DB6 = (c >> 6) &0x01;	LCD_DB5 = (c >> 5) &0x01;	LCD_DB4 = (c >> 4) &0x01;	LCD_STROBE;	LCD_DB7 = (c >> 3) &0x01;	LCD_DB6 = (c >> 2) &0x01;	LCD_DB5 = (c >> 1) &0x01;	LCD_DB4 =  c & 0x01;	LCD_STROBE;	DelayUs(80);/*     PORTD = (PORTD & 0x0F) |  (c & 0xF0);     LCD_STROBE;     PORTD = (PORTD & 0x0F) |  (c << 4);     LCD_STROBE;     DelayUs(80); */}void lcd_clear(void){   LCD_RS = 0;   lcd_write(0x01);   DelayMs(4);         //DelayMs(4)}void lcd_puts(const char * s){   LCD_RS = 1;   // write characters   while(*s)      lcd_write(*s++);}void lcd_putch(char c){   LCD_RS = 1;   // write characters/*   PORTD = (PORTD & 0x0F) |  (c & 0xF0);   LCD_STROBE;   PORTD = (PORTD & 0x0F) |  (c << 4);   LCD_STROBE;   DelayUs(80); */   lcd_write(c);}void lcd_gotoxy(unsigned char pos, unsigned char line){	unsigned char addr = 0x80;   LCD_RS = 0;    if (line > 1)			//linia 2   		addr = 0xc0;   lcd_write(addr + pos);}   void lcd_init(void){   DelayMs(40);	   LCD_RS = 0;   LCD_RW = 0;      PORTD = (PORTD & 0x0F) | (0x30);   // reset 1   LCD_STROBE;   DelayMs(5);   LCD_STROBE;     PORTD = (PORTD & 0x0F) | (0x30);  // reset 2   LCD_STROBE;   DelayUs(160);   LCD_STROBE;      PORTD = (PORTD & 0x0F) | (0x30);  // reset 3   LCD_STROBE;   DelayUs(160);   LCD_STROBE;   //-------------INIT---------------   PORTD = (PORTD & 0x0F) | (0x20);		//4 bit   LCD_STROBE;   DelayUs(200);   LCD_STROBE;      PORTD = (PORTD & 0x0F) | (0x20);		//4 bit, 2 line   LCD_STROBE;   PORTD = (PORTD & 0x0F) | (0x80);   LCD_STROBE;    PORTD = (PORTD & 0x0F);            //Display clear   LCD_STROBE;   PORTD = (PORTD & 0x0F) | (0x10);   LCD_STROBE;   DelayMs(4);      PORTD = (PORTD & 0x0F);            //Entry mod set   LCD_STROBE;   PORTD = (PORTD & 0x0F) | (0x60);   LCD_STROBE;   DelayUs(60);           PORTD = (PORTD & 0x0F);            //Display on,cursor off   LCD_STROBE;   PORTD = (PORTD & 0x0F) | (0xc0);   LCD_STROBE;   DelayMs(5);   }
si pt 4MHz "delay.h":
// fisierul delay.h#ifndef	XTAL_FREQ#define	XTAL_FREQ	4MHZ		/* Crystal frequency in MHz */#endif#define	MHZ	*1000L			/* number of kHz in a MHz */#define	KHZ	*1			/* number of kHz in a kHz */#if	XTAL_FREQ >= 12MHZ#define	DelayUs(x)	{ unsigned char _dcnt; \			  _dcnt = (x)*((XTAL_FREQ)/(12MHZ)); \			  while(--_dcnt != 0) \				  continue; }#else#define	DelayUs(x)	{ unsigned char _dcnt; \			  _dcnt = (x)/((12MHZ)/(XTAL_FREQ))|1; \			  while(--_dcnt != 0) \				  continue; }#endifextern void DelayMs(unsigned char);
si "delay.c":
// fisierul delay.c#include	"delay.h"voidDelayMs(unsigned char cnt){#if	XTAL_FREQ <= 2MHZ	do {		DelayUs(996);	} while(--cnt);#endif#if    XTAL_FREQ > 2MHZ		unsigned char	i;	do {		i = 4;		do {			DelayUs(250);		} while(--i);	} while(--cnt);#endif}
Eu am luat lcd de la Capodimonte, deci cum am zis mai sus, daca nu merge mai intreaba pe forum cum se initializeaza modelul tau.

Share this post


Link to post
Share on other sites
Guest vaidaionutradu

mersi mult....raman dator peste masura....sper sa mearga

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

×
×
  • 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.