Witam, otrzymałem od elektrody kod programu napisany w c do obsługi wyświetlacza 8 znakowego w np Astrze, próbowałem go przerobić na wyświetlacz 10 znakowy w Vectrze ale niestety wyświetlacz nie reaguje, czy może ktoś zerknąć co mogło by być źle?
#include <avr/io.h>
#include <avr/interrupt.h>
#include "lib\delay.c"
unsigned char dana,i, t,s,d,j ,cnt1, z1, p;
unsigned int liczba,b,a,cnt; //zmienne
char wi;
void puls_us(void)
{
delayus(400);
}
void startpuls(void) //czasy
{
delayus(200);
}
void sek(void)
{
delayms(1000);
}
void start(void)
{
DDRB = 0xFF;
PORTB=0xFF; //strat
PORTB |=_BV(3); //mrq=0;
puls_us();
PORTB &=~_BV(3); //mrq=1; //bit startu na magistrali I2C START
PORTB &=~_BV(1); //sda=1;
PORTB &=~_BV(2); //scl=1;
startpuls();
PORTB |=_BV(1); //sda=0;
startpuls();
PORTB |=_BV(2); //scl=0;
startpuls();
}
void stop(void) //STOP
{
PORTB &=~_BV(3); //mrq=1;
PORTB &=~_BV(2); //scl=1;
startpuls();
PORTB &=~_BV(1); //sda=1;
//portb=28;
}
void send(unsigned char dana) // wysyłanie
{
for(i=0;i<8;i++) //będzie 8 bitów
{
if(dana&0x80) //badaj najstarszy bit wysyłanego znaku
{
PORTB &=~_BV(1); //sda=1; //wyślij "1"
}
else
{
PORTB |=_BV(1); //sda=0; //wyślij "0"
}
PORTB &=~_BV(2); //scl=1;
puls_us();
PORTB |=_BV(2); //scl=0;
puls_us();
dana<<=1; //przygotuj następny bit do wysłania
}
PORTB &=~_BV(1); //sda=1;
PORTB &=~_BV(2); //scl=1;
puls_us();
PORTB |=_BV(2); //scl=0;
PORTB |=_BV(1); //sda=0;
PORTB |=_BV(3); //mrq=0;
puls_us();
}
char table[10]={0x61,0x62,0x64,0x67,0x68,0x6b,0x6d,0x6e,0x70,0x73}; //tablica cyf
void powitanie(void)
{
for (p=0; p<10;p++) {
start();
startpuls();
send(0x9B);
startpuls();
PORTB |=_BV(3); //mrq=0;
startpuls();
send(0x01);
send(0x01);
send(0x01);
send(0x77);
send(0x78);
send(0x79);
send(0x71);
send(0x72);
send(0x73);
send(0x74);
send(0x75);
send(0x76);
send(0x77);
stop();
delayms(100);
}
for (p=0;p<10;p++) {
start();
startpuls();
send(0x9B);
startpuls();
PORTB |=_BV(3); //mrq=0;
startpuls();
send(0x01);
send(0x01);
send(0x01);
send(0x77);
send(0x78);
send(0x79);
send(0x71);
send(0x72);
send(0x73);
send(0x74);
send(0x75);
send(0x76);
send(0x77);
stop();
delayms(100);
}
wi++;
}
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
void main () { //główny program
DDRB = 0xFF;
PORTB=0xFF;
while(1) //(wi<1)
{
powitanie();
}
}