Witam wszystkich.
Oto mój programik do obsługi LCD który miał wyświetlać całe wyrazy na nim.Jednak coś nie chce działać do końca.Może ktoś mógłby go sprawdzić u siebie bo sam już nie wiem czy to wina sprzętu czy wina programu - pojedyncze litery wyświetla:
pozdrawiam wszystkich:]
Problem , to "zakazane" słowo w tytule tematu - regulamin
Tytuł poprawiłem.
[zumek]
Oto mój programik do obsługi LCD który miał wyświetlać całe wyrazy na nim.Jednak coś nie chce działać do końca.Może ktoś mógłby go sprawdzić u siebie bo sam już nie wiem czy to wina sprzętu czy wina programu - pojedyncze litery wyświetla:
#include <avr/io.h>
#include<inttypes.h>
#include<avr/pgmspace.h>
#define cbi(sfr, bit) (_SFR_BYTE(sfr) &= ~_BV(bit))
#define sbi(sfr, bit) (_SFR_BYTE(sfr) |= _BV(bit))
#define LCD_PORT PORTB
#define lcd_rs 2
#define lcd_e 3
#define CR 0x0a
void czekaj(unsigned long pt) ///petla opozniajaca
{
#define tau 10.38
unsigned char tp1;
for(;pt>0;pt--)
{
for(tp1=255;tp1!=0;tp1--)
{
asm ("nop");
}
}
}
void instrukcja( char instr)
{
cbi (PORTB,lcd_rs);
cbi (PORTB,lcd_e);
PORTB=(PORTB&0x0f)|(instr&0xf0);
sbi (PORTB,lcd_e);
asm("nop");
asm("nop");
asm("nop");
czekaj(10L);
cbi (PORTB,lcd_rs);
cbi (PORTB,lcd_e);
PORTB=(PORTB&0x0f)|((instr&0x0f)<<4);
sbi (PORTB,PB3);
asm("nop");
asm("nop");
asm("nop");
cbi(PORTB,lcd_e);
czekaj(10L);
}
void LCDdata(char data)
{
sbi (PORTB,lcd_rs);
cbi (PORTB,lcd_e);
PORTB=(PORTB&0x0f)|(data&0xf0);
sbi (PORTB,lcd_e);
asm("nop");
asm("nop");
asm("nop");
czekaj(15L);
sbi (PORTB,lcd_rs);
cbi (PORTB,lcd_e);
PORTB=(PORTB&0x0f)|((data&0x0f)<<4);
sbi (PORTB,lcd_e);
czekaj(50*tau);
asm("nop");
asm("nop");
asm("nop");
czekaj(15);
}
void LCDstr(char *str)
{
int n=0;
while(0!=str[n])
{
LCDdata(str[n]);
n++;
}
}
int main(void)
{
PORTB=0x03; //pb0-pb3 - podciągniecia
DDRB=0xff; //portb-wyjscie
czekaj(45*tau); //stabilizowanie napiecia
cbi(PORTB,lcd_rs);
cbi(PORTB,lcd_e);
PORTB=(PORTB&0x00)|0x20;
sbi(PORTB,PB3);
asm("nop");
asm("nop");
asm("nop");
cbi(PORTB,lcd_e);
czekaj(50);
instrukcja(0x28); //interfejs 4 bitowy , 2 linie,znak 5x7
instrukcja(0x08); //wylacz LCD,wylacz kursor,wylacz mruganie
instrukcja(0x01); //czysc lcd
instrukcja(0x01);
instrukcja(0x0f);
czekaj(2*tau);
while(1)
{
instrukcja(0x0f);
LCDstr("ja");
return(0);
}
}
pozdrawiam wszystkich:]
Problem , to "zakazane" słowo w tytule tematu - regulamin
Tytuł poprawiłem.
[zumek]