Подскажите пожалуйста, в чем может быть трабла в коде ? В протеусе собрал схемку, хочу просимуировать как будет работать. Протеус ругается пишет
[HD44780]Attemted to read after writing a single nibble
[HD44780]Attemted to write after reading a single nibble
Вот исходный код
Код: Выделить всё
/*********************************************
This program was produced by the
CodeWizardAVR V1.24.0 Standard
Automatic Program Generator
© Copyright 1998-2003 HP InfoTech s.r.l.
http://www.hpinfotech.ro
e-mail:office@hpinfotech.ro
Project :
Version : 1.0.3.2
Date : 2005.09.26
Modified: 2007.08.30
Author : Scienceprog.com
Company :
Comments:
Chip type : AT90S2313
Clock frequency : 4,000000 MHz
Memory model : Tiny
External SRAM size : 0
Data Stack size : 32
*********************************************/
// Alphanumeric LCD Module functions
//PORTB - LCD
//----------------------------
//Bit0 - RS(LCD Pin4)
//Bit1 - RD(LCD Pin4)
//Bit2 - EN(LCD Pin4)
//Bit3 - Neprijungtas
//Bit4 - DB4(LCD Pin4)
//Bit5 - DB5(LCD Pin4)
//Bit6 - DB6(LCD Pin4)
//Bit7 - DB7(LCD Pin4)
#include <90s2313.h>
#asm
.equ __lcd_port=0x18
#endasm
#include <lcd.h> //LCD control library
#include <delay.h> //Delay control library
#define MinUp PIND.0 //Button PIND0 Increases minutes
#define MinDown PIND.1 //Button PIND1 Decreases minutes
#define SecUp PIND.4 //Button PIND4 Increases seconds
#define SecDown PIND.5 //Button PIND4 Decreases seconds
#define Rellay_On PORTD.6=1 //Relay on by sending "1" to PIND6
#define Rellay_Off PORTD.6=0 //Relay off by sending "0" to PIND6
#define Start PIND.3 //Start Button
#define Stop PIND.2 //Stop/Clear Button
typedef unsigned char byte;
// Declare your global variables here
unsigned char temp1, temp2, temp3,temp4, temp5, temp6, laikas, end_check;
char h1, h0, m1, m0, s1, s0, p2,p1,p0;
char IsStart, IsStop, IsClear;
unsigned int pp,pp1;
//unsigned int total_secs;
//float BarStep, Bar;
//Define LCD simbol
flash byte kaire[8]={
0b1000000,
0b0100000,
0b0010000,
0b0001000,
0b0000100,
0b0000010,
0b0000001,
0b0000000
};
//Symbol addressses for rotation effect
flash byte sleshai[8]={
0b00000000,
0b01111100,
0b00101111,
0b10110000,
0b00000000,
0b01111100,
0b00101111,
0b10110000
};
//Send simbol to LCD CGRAM
void define_char(byte flash *pc,byte char_code){
byte i,a;
a=(char_code<<3)|0x40;
for (i=0; i<8; i++)
lcd_write_byte(a++,*pc++);
}
//Funscion displays time on LCD at (9,1) position
void disp_time(void){
lcd_gotoxy(8,1);
lcd_putchar(h1|0x30);
lcd_gotoxy(9,1);
lcd_putchar(h0|0x30);
lcd_gotoxy(10,1);
lcd_putchar(0x3A);
lcd_gotoxy(11,1);
lcd_putchar(m1|0x30);
lcd_gotoxy(12,1);
lcd_putchar(m0|0x30);
lcd_gotoxy(13,1);
lcd_putchar(0x3A);
lcd_gotoxy(14,1);
lcd_putchar(s1|0x30);
lcd_gotoxy(15,1);
lcd_putchar(s0|0x30);
}
//Setting time function (max 60 min ir 60 sec)
void peep(unsigned int koef)
{
DDRB.3=1;
PORTB.3=0;
temp2=0;
while (temp2<=50)
{
for(pp=1;pp<koef;pp++){}
PORTB.3=1;
delay_us(100);
temp2++;
PORTB.3=0;
delay_us(100);
}
}
void settime (void)
{
// DDRD=0b01000000;
// PORTD=0b00111111;
lcd_gotoxy(0,0);
lcd_putsf(" UV-80 v1.0 ");
lcd_gotoxy(0,1);
lcd_putsf(" 2007.08.30 ");
delay_ms(2000);
lcd_clear();
while((IsStart&1)!=1) // Program loop
{
// lcd_clear();
// delay_ms(15);
lcd_gotoxy(0,0);
lcd_putsf("Time delay ");
disp_time();
PORTD.0=1;
PORTD.1=1;
PORTD.2=1;
PORTD.3=1;
PORTD.4=1;
PORTD.5=1;
DDRD.0=0;
DDRD.1=0;
DDRD.3=0;
DDRD.2=0;
DDRD.4=0;
DDRD.5=0;
temp6++; // small delay
//check if MinUp button is pressed
if ((MinUp&1)!=1)
{
// delay_ms(25);
// Increment minutes
if (m0!=9) {m0++;}
else if (m1!=5) {m1++; m0=0;}
else {m0=0; m1=0;}
//Buzzer
peep(8);
// Wait for button release
while ((MinUp&1)==0){}
}
//check if MinDown button is pressed
if ((MinDown&1)!=1)
{
//Dekrement Minutes
if (m0!=0) {m0--;}
else if (m1!=0) {m1--; m0=9;}
else {m0=9; m1=5;}
// Wait for button release
peep(6);
while ((MinDown&1)==0){}
}
//
temp6--;
//check if SecUp button is pressed
if ((SecUp&1)!=1)
{
if (s0!=9) {s0++;}
else if (s1!=5) {s1++; s0=0;}
else {s0=0; s1=0;}
// Wait for button release
peep(4);
while ((SecUp&1)==0){}
}
//check if SecDown button is pressed
if ((SecDown&1)!=1)
{
//Dekrement Seconds
if (s0!=0) {s0--;}
else if (s1!=0) {s1--; s0=9;}
else {s0=9; s1=5;}
// Wait for button release
peep(2);
while ((SecDown&1)==0){}
}
if ((Start)!=1)
{
IsStart=1;
peep(8);
peep(8);
peep(8);
peep(8);
delay_ms(10);
peep(6);
peep(6);
peep(6);
delay_ms(8);
peep(4);
peep(4);
delay_ms(5);
peep(2);
while ((Start)==0){}
}
}
}
void main(void) //Main program
{
for (pp1=1;pp1<50;pp1++)
{
peep(5);
}
PORTB=0x00;
DDRB=0xFF;
PORTD=0x00;
DDRD=0x7F;
// Timer/Counter 0 initialization
TCCR0=0x00;
TCNT0=0x00;
// Timer/Counter 1 initialization
TCCR1A=0x00;
TCCR1B=0x00;
TCNT1H=0x00;
TCNT1L=0x00;
OCR1H=0x00;
OCR1L=0x00;
// Timer(s)/Counter(s) Interrupt(s) initialization
TIMSK=0x00;
//Initial values
temp1=0;
temp3=0;
temp4=0;
temp5=0;
temp6=0;
laikas=0;
IsStart=0;
IsStop=0;
IsClear=0;
//Initial time values
h1=0;//Leave always 0
h0=0;//Leave always 0
m1=0;
m0=3;
s1=0;
s0=0;
// LCD module initialization
lcd_init(16);
Rellay_Off;
//define custom char on LCD CGRAM
define_char(kaire,0);
delay_ms(2000); //1 second
lcd_clear();
//lcd_putchar(0);
//Time input
settime();
lcd_gotoxy(0,0);
lcd_putsf("Relay On");
DDRD.6=1;
Rellay_On;//Start relay and start coundown
delay_ms(7000);
DDRD.2=0;
DDRD.3=0;
PORTD.2=1;
PORTD.3=1;
while (!end_check)//
{
//Char animation on LCD ********************
lcd_gotoxy(0,1);
delay_ms(1000);
lcd_putchar(sleshai[temp3]);
temp3++;
if (temp3==8) temp3=0;
if (temp1==0)
{
lcd_gotoxy(0,0);
lcd_putsf("!!!!!Warning!!!!!");
temp1++;
}
else if (temp1==1)
{
lcd_gotoxy(0,0);
lcd_putsf("!!! UV !!!");
temp1++;
}
else if (temp1==2)
{
lcd_gotoxy(0,0);
lcd_putsf("!!!!!Exposure!!!!");
temp1++;
}
else if (temp1==3)
{
lcd_gotoxy(0,0);
lcd_putsf("!!Do not look!!");
temp1=0;
}
//Time countdown*******************
if (s0!=0) {s0--; end_check=0;}
else if (s1!=0) {s1--; s0=9; end_check=0;}
else if (m0!=0) {m0--; s1=5;s0=9;end_check=0;}
else if (m1!=0) {m1--; m0=9;s1=5;s0=9;end_check=0;}
else end_check=1;
//Exposure over***************
if (!end_check) disp_time();
else {lcd_gotoxy(0,0); lcd_putsf("****Finished!***"); Rellay_Off; break;}//Stop relay
}
while (1)
{
// Place your code here
lcd_clear();
delay_ms(1000);
peep(15);
peep(15);
peep(15);
peep(15);
peep(15);
peep(15);
peep(15);
peep(15);
lcd_gotoxy(0,0);
lcd_putsf("****Finished!***");
delay_ms(1000);
peep(10);
peep(10);
peep(10);
peep(10);
peep(10);
peep(10);
peep(10);
};
}В программировании новичок, хочу собрать устройство таймера http://www.scienceprog.com/ultraviolet- ... -exposure/

