Вывод на LCD wh1602
Добавлено: Пн янв 31, 2011 22:46:42
Написал программу в СVAVR компилируется вот только пытался прошить да на экране пусто
подскажите может где ошибка есть
#include <mega8.h>
#include <stdio.h>
// Alphanumeric LCD Module functions
#asm
.equ __lcd_port=0x18
#endasm
#include <lcd.h>
#define A PIND.2
//
#define B PIND.3
// Declare your global variables here
unsigned int j = 0;
// Timer 0 overflow interrupt service routine
interrupt [TIM0_OVF] void timer0_ovf_isr(void)
{
if (A==0 && B==1)
{
j++;
};
if (B==0 && A==1)
{
j--;
};
}
void main(void)
{
// Declare your local variables here
char text[16]; // Buffer
// Input/Output Ports initialization
// Port B
PORTB=0x00;
DDRB=0x00;
// Port C
PORTC=0x00;
DDRC=0x00;
// Port D
PORTD=0x00;
DDRD=0x00;
// Timer/Counter 0 initialization
// Clock source: System Clock
// Clock value: 7,813 kHz
// Mode: Output Compare
// OC0 output: Disconnected
TCCR0=0x05;
TCNT0=0x00;
// Timer/Counter 1 initialization
// Clock source: System Clock
// Clock value: Timer 1 Stopped
// Mode: Output Compare
// OC1A output: Discon.
// OC1B output: Discon.
// Noise Canceler: Off
// Input Capture on Falling Edge
TCCR1A=0x00;
TCCR1B=0x00;
TCNT1H=0x00;
TCNT1L=0x00;
OCR1AH=0x00;
OCR1AL=0x00;
OCR1BH=0x00;
OCR1BL=0x00;
// Timer/Counter 2 initialization
// Clock source: System Clock
// Clock value: Timer 2 Stopped
// Mode: Output Compare
// OC2 output: Disconnected
TCCR2=0x00;
ASSR=0x00;
TCNT2=0x00;
OCR2=0x00;
// External Interrupt(s) initialization
// INT0: Off
// INT1: Off
MCUCR=0x00;
// Timer(s)/Counter(s) Interrupt(s) initialization
TIMSK=0x01;
// Analog Comparator initialization
// Analog Comparator: Off
// Analog Comparator Input Capture by Timer/Counter 1: Off
ACSR=0x80;
// LCD module initialization
lcd_init(16);
// Global enable interrupts
#asm("sei")
lcd_putsf("Displaytest");
while (1)
{
sprintf(text, " j = %i", j); // fill buffer
lcd_gotoxy(0,1); // cursor at 0,1
lcd_puts(text); // output text
lcd_gotoxy(10,0);
lcd_putchar(j); // display ASCII
};
}
подскажите может где ошибка есть
#include <mega8.h>
#include <stdio.h>
// Alphanumeric LCD Module functions
#asm
.equ __lcd_port=0x18
#endasm
#include <lcd.h>
#define A PIND.2
//
#define B PIND.3
// Declare your global variables here
unsigned int j = 0;
// Timer 0 overflow interrupt service routine
interrupt [TIM0_OVF] void timer0_ovf_isr(void)
{
if (A==0 && B==1)
{
j++;
};
if (B==0 && A==1)
{
j--;
};
}
void main(void)
{
// Declare your local variables here
char text[16]; // Buffer
// Input/Output Ports initialization
// Port B
PORTB=0x00;
DDRB=0x00;
// Port C
PORTC=0x00;
DDRC=0x00;
// Port D
PORTD=0x00;
DDRD=0x00;
// Timer/Counter 0 initialization
// Clock source: System Clock
// Clock value: 7,813 kHz
// Mode: Output Compare
// OC0 output: Disconnected
TCCR0=0x05;
TCNT0=0x00;
// Timer/Counter 1 initialization
// Clock source: System Clock
// Clock value: Timer 1 Stopped
// Mode: Output Compare
// OC1A output: Discon.
// OC1B output: Discon.
// Noise Canceler: Off
// Input Capture on Falling Edge
TCCR1A=0x00;
TCCR1B=0x00;
TCNT1H=0x00;
TCNT1L=0x00;
OCR1AH=0x00;
OCR1AL=0x00;
OCR1BH=0x00;
OCR1BL=0x00;
// Timer/Counter 2 initialization
// Clock source: System Clock
// Clock value: Timer 2 Stopped
// Mode: Output Compare
// OC2 output: Disconnected
TCCR2=0x00;
ASSR=0x00;
TCNT2=0x00;
OCR2=0x00;
// External Interrupt(s) initialization
// INT0: Off
// INT1: Off
MCUCR=0x00;
// Timer(s)/Counter(s) Interrupt(s) initialization
TIMSK=0x01;
// Analog Comparator initialization
// Analog Comparator: Off
// Analog Comparator Input Capture by Timer/Counter 1: Off
ACSR=0x80;
// LCD module initialization
lcd_init(16);
// Global enable interrupts
#asm("sei")
lcd_putsf("Displaytest");
while (1)
{
sprintf(text, " j = %i", j); // fill buffer
lcd_gotoxy(0,1); // cursor at 0,1
lcd_puts(text); // output text
lcd_gotoxy(10,0);
lcd_putchar(j); // display ASCII
};
}