سلام
من تو winavr یک مبتدی محسوب میشم.
خواستم lcd راه اندازی کنم که بعد از کامپایل دو تا error داشتم.
اگر ممکن است راهنمایی بفرمایید.
این مداری که قرار است شبیه سازی شود.

اینم عکس از error ها و محیط برنامه.

اینم برنامه main
// generated with AvrWiz (by g@greschenz.de)
// -----------------------------------------
// cpu: ATmega8
// speed: 16 mhz (max: 16 mhz)
// voltage: 5 V
// ram: 1024 bytes (0x0060-0x045f)
// rom: 4096 bytes (0x0000-0x0fff)
// eeprom: 512 bytes (0x0000-0x01ff)
// -----------------------------------------
#include <avr/io.h>
#include <avr/interrupt.h>
#include"lcd_lib.h"
#if !defined (__AVR_ATmega8__)
#error __AVR_ATmega8__ not defined !
#endif
#if !defined (F_CPU)
#define F_CPU 16000000
#endif
#define RAMSTART 0x0060
#define RAMSIZE (RAMEND-RAMSTART)
#define sleep()
ISR(INT0_vect) // External Interrupt Request 0
{
// ... ;
}
ISR(TIMER1_OVF_vect) // Timer/Counter1 Overflow
{
TCNT1H = 0;
TCNT1L = 0;
// ... ;
}
// ---------------
// --- ext irq ---
// ---------------
void ExtIrq_Init(void)
{
MCUCR |= (1<<ISC01) | (1<<ISC00); // The rising edge of INT0 generates an interrupt request
GICR |= (1<<INT0); // External Interrupt Request 0 Enable
}
// --------------
// --- Timer1 ---
// --------------
void Timer1_Init(void)
{
// Timer1 settings: ~ 65536 ticks (4096 us / 4.096 ms / 0.004096 sec)
TCCR1B = (1<<CS10); // CLK/1
TIMSK = (1 << TOIE1); // Timer/Counter1 Overflow Interrupt Enable
TCNT1H = 0;
TCNT1L = 0;
}
// --------------
// --- main() ---
// --------------
int main()
{
DDRB = 0; // iiiiiiii
PORTB = 0; // iiiiiiii
DDRC = 0; // -iiiiiii
PORTC = 0; // -iiiiiii
DDRD = 255; // oooooooo
PORTD = 0; // iiiiiiii
LCDinit();//init LCD bit, dual line, cursor right
LCDclr();//clears LCD
ExtIrq_Init();
Timer1_Init();
sei(); // enable interrupts
for (;
sleep();
return 0;
}
اینم کتابخانه Lcd_lib
#endif
من تو winavr یک مبتدی محسوب میشم.
خواستم lcd راه اندازی کنم که بعد از کامپایل دو تا error داشتم.
اگر ممکن است راهنمایی بفرمایید.
این مداری که قرار است شبیه سازی شود.

اینم عکس از error ها و محیط برنامه.

اینم برنامه main
// generated with AvrWiz (by g@greschenz.de)
// -----------------------------------------
// cpu: ATmega8
// speed: 16 mhz (max: 16 mhz)
// voltage: 5 V
// ram: 1024 bytes (0x0060-0x045f)
// rom: 4096 bytes (0x0000-0x0fff)
// eeprom: 512 bytes (0x0000-0x01ff)
// -----------------------------------------
#include <avr/io.h>
#include <avr/interrupt.h>
#include"lcd_lib.h"
#if !defined (__AVR_ATmega8__)
#error __AVR_ATmega8__ not defined !
#endif
#if !defined (F_CPU)
#define F_CPU 16000000
#endif
#define RAMSTART 0x0060
#define RAMSIZE (RAMEND-RAMSTART)
#define sleep()
ISR(INT0_vect) // External Interrupt Request 0
{
// ... ;
}
ISR(TIMER1_OVF_vect) // Timer/Counter1 Overflow
{
TCNT1H = 0;
TCNT1L = 0;
// ... ;
}
// ---------------
// --- ext irq ---
// ---------------
void ExtIrq_Init(void)
{
MCUCR |= (1<<ISC01) | (1<<ISC00); // The rising edge of INT0 generates an interrupt request
GICR |= (1<<INT0); // External Interrupt Request 0 Enable
}
// --------------
// --- Timer1 ---
// --------------
void Timer1_Init(void)
{
// Timer1 settings: ~ 65536 ticks (4096 us / 4.096 ms / 0.004096 sec)
TCCR1B = (1<<CS10); // CLK/1
TIMSK = (1 << TOIE1); // Timer/Counter1 Overflow Interrupt Enable
TCNT1H = 0;
TCNT1L = 0;
}
// --------------
// --- main() ---
// --------------
int main()
{
DDRB = 0; // iiiiiiii
PORTB = 0; // iiiiiiii
DDRC = 0; // -iiiiiii
PORTC = 0; // -iiiiiii
DDRD = 255; // oooooooo
PORTD = 0; // iiiiiiii
LCDinit();//init LCD bit, dual line, cursor right
LCDclr();//clears LCD
ExtIrq_Init();
Timer1_Init();
sei(); // enable interrupts
for (;

return 0;
}
اینم کتابخانه Lcd_lib
//************************************************** ***************************
//
// File Name : 'lcd_lib.h'
// Title : 8 and 4 bit LCd interface
// Author : Scienceprog.com - Copyright (C) 2007
// Created : 2007-03-29
// Revised : 2007-08-08
// Version : 1.0
// Target MCU : Atmel AVR series
//
// This code is distributed under the GNU Public License
// which can be found at http://www.gnu.org/licenses/gpl.txt
//
//************************************************** ***************************
#ifndef LCD_LIB
#define LCD_LIB
#include <inttypes.h>
//***********************************************
//you must define these parameters
#define LCD_RS 0 //define MCU pin connected to LCD RS
#define LCD_RW 1 //define MCU pin connected to LCD R/W
#define LCD_E 2 //define MCU pin connected to LCD E
#define LCD_D4 4 //define MCU pin connected to LCD D4
#define LCD_D5 5 //define MCU pin connected to LCD D5
#define LCD_D6 6 //define MCU pin connected to LCD D6
#define LCD_D7 7 //define MCU pin connected to LCD D7
#define LDP PORTD //define MCU port connected to LCD data pins
#define LCP PORTD //define MCU port connected to LCD control pins
#define LDDR DDRD //define MCU direction register for port connected to LCD data pins
#define LCDR DDRD //define MCU direction register for port connected to LCD control pins
//***********************************************
#define LCD_CLR 0 //DB0: clear display
#define LCD_HOME 1 //DB1: return to home position
#define LCD_ENTRY_MODE 2 //DB2: set entry mode
#define LCD_ENTRY_INC 1 //DB1: increment
#define LCD_ENTRY_SHIFT 0 //DB2: shift
#define LCD_ON_CTRL 3 //DB3: turn lcd/cursor on
#define LCD_ON_DISPLAY 2 //DB2: turn display on
#define LCD_ON_CURSOR 1 //DB1: turn cursor on
#define LCD_ON_BLINK 0 //DB0: blinking cursor
#define LCD_MOVE 4 //DB4: move cursor/display
#define LCD_MOVE_DISP 3 //DB3: move display (0-> move cursor)
#define LCD_MOVE_RIGHT 2 //DB2: move right (0-> left)
#define LCD_FUNCTION 5 //DB5: function set
#define LCD_FUNCTION_8BIT 4 //DB4: set 8BIT mode (0->4BIT mode)
#define LCD_FUNCTION_2LINES 3 //DB3: two lines (0->one line)
#define LCD_FUNCTION_10DOTS 2 //DB2: 5x10 font (0->5x7 font)
#define LCD_CGRAM 6 //DB6: set CG RAM address
#define LCD_DDRAM 7 //DB7: set DD RAM address
// reading:
#define LCD_BUSY 7 //DB7: LCD is busy
#define LCD_LINES 2 //visible lines
#define LCD_LINE_LENGTH 16 //line length (in characters)
// cursor position to DDRAM mapping
#define LCD_LINE0_DDRAMADDR 0x00
#define LCD_LINE1_DDRAMADDR 0x40
#define LCD_LINE2_DDRAMADDR 0x14
#define LCD_LINE3_DDRAMADDR 0x54
// progress bar defines
#define PROGRESSPIXELS_PER_CHAR 6
//private macros
#define _lcd_mini_delay() asm("NOP"
;\
asm("NOP"
;asm("NOP"
;asm("NOP"
;asm("NOP"
void LCDinit(void); //Initializes LCD
void LCDsendChar(uint8_t); //forms data ready to send to 74HC164
void LCDsendCommand(uint8_t); //forms data ready to send to 74HC164
void LCDstring(uint8_t*, uint8_t); //Outputs string to LCD
void LCDGotoXY(uint8_t, uint8_t); //Cursor to X Y position
void CopyStringtoLCD(const char*, uint8_t, uint8_t);//copies flash string to LCD at x,y
void LCDdefinechar(const uint8_t *,uint8_t);//write char to LCD CGRAM
void LCDshiftRight(uint8_t); //shift by n characters Right
void LCDshiftLeft(uint8_t); //shift by n characters Left
void LCDcursorLeft(uint8_t); //Shift cursor left by n
void LCDcursorRight(uint8_t); //shif cursor right by n
void LCDprintBCD(int val,char dotPoint);
void LCDclr(void); //Clears LCD
void LCDhome(void); //LCD cursor home
void LCDcursorOn(void); //Underline cursor ON
void LCDcursorOnBlink(void); //Underline blinking cursor ON
void LCDcursorOFF(void); //Cursor OFF
void LCDblank(void); //LCD blank but not cleared
void LCDvisible(void); //LCD visible
// displays a horizontal progress bar at the current cursor location
// <progress> is the value the bargraph should indicate
// <maxprogress> is the value at the end of the bargraph
// <length> is the number of LCD characters that the bargraph should cover
//adapted from AVRLIB - displays progress only for 8 bit variables
void LCDprogressBar(uint8_t progress, uint8_t maxprogress, uint8_t length);
//
// File Name : 'lcd_lib.h'
// Title : 8 and 4 bit LCd interface
// Author : Scienceprog.com - Copyright (C) 2007
// Created : 2007-03-29
// Revised : 2007-08-08
// Version : 1.0
// Target MCU : Atmel AVR series
//
// This code is distributed under the GNU Public License
// which can be found at http://www.gnu.org/licenses/gpl.txt
//
//************************************************** ***************************
#ifndef LCD_LIB
#define LCD_LIB
#include <inttypes.h>
//***********************************************
//you must define these parameters
#define LCD_RS 0 //define MCU pin connected to LCD RS
#define LCD_RW 1 //define MCU pin connected to LCD R/W
#define LCD_E 2 //define MCU pin connected to LCD E
#define LCD_D4 4 //define MCU pin connected to LCD D4
#define LCD_D5 5 //define MCU pin connected to LCD D5
#define LCD_D6 6 //define MCU pin connected to LCD D6
#define LCD_D7 7 //define MCU pin connected to LCD D7
#define LDP PORTD //define MCU port connected to LCD data pins
#define LCP PORTD //define MCU port connected to LCD control pins
#define LDDR DDRD //define MCU direction register for port connected to LCD data pins
#define LCDR DDRD //define MCU direction register for port connected to LCD control pins
//***********************************************
#define LCD_CLR 0 //DB0: clear display
#define LCD_HOME 1 //DB1: return to home position
#define LCD_ENTRY_MODE 2 //DB2: set entry mode
#define LCD_ENTRY_INC 1 //DB1: increment
#define LCD_ENTRY_SHIFT 0 //DB2: shift
#define LCD_ON_CTRL 3 //DB3: turn lcd/cursor on
#define LCD_ON_DISPLAY 2 //DB2: turn display on
#define LCD_ON_CURSOR 1 //DB1: turn cursor on
#define LCD_ON_BLINK 0 //DB0: blinking cursor
#define LCD_MOVE 4 //DB4: move cursor/display
#define LCD_MOVE_DISP 3 //DB3: move display (0-> move cursor)
#define LCD_MOVE_RIGHT 2 //DB2: move right (0-> left)
#define LCD_FUNCTION 5 //DB5: function set
#define LCD_FUNCTION_8BIT 4 //DB4: set 8BIT mode (0->4BIT mode)
#define LCD_FUNCTION_2LINES 3 //DB3: two lines (0->one line)
#define LCD_FUNCTION_10DOTS 2 //DB2: 5x10 font (0->5x7 font)
#define LCD_CGRAM 6 //DB6: set CG RAM address
#define LCD_DDRAM 7 //DB7: set DD RAM address
// reading:
#define LCD_BUSY 7 //DB7: LCD is busy
#define LCD_LINES 2 //visible lines
#define LCD_LINE_LENGTH 16 //line length (in characters)
// cursor position to DDRAM mapping
#define LCD_LINE0_DDRAMADDR 0x00
#define LCD_LINE1_DDRAMADDR 0x40
#define LCD_LINE2_DDRAMADDR 0x14
#define LCD_LINE3_DDRAMADDR 0x54
// progress bar defines
#define PROGRESSPIXELS_PER_CHAR 6
//private macros
#define _lcd_mini_delay() asm("NOP"

asm("NOP"




void LCDinit(void); //Initializes LCD
void LCDsendChar(uint8_t); //forms data ready to send to 74HC164
void LCDsendCommand(uint8_t); //forms data ready to send to 74HC164
void LCDstring(uint8_t*, uint8_t); //Outputs string to LCD
void LCDGotoXY(uint8_t, uint8_t); //Cursor to X Y position
void CopyStringtoLCD(const char*, uint8_t, uint8_t);//copies flash string to LCD at x,y
void LCDdefinechar(const uint8_t *,uint8_t);//write char to LCD CGRAM
void LCDshiftRight(uint8_t); //shift by n characters Right
void LCDshiftLeft(uint8_t); //shift by n characters Left
void LCDcursorLeft(uint8_t); //Shift cursor left by n
void LCDcursorRight(uint8_t); //shif cursor right by n
void LCDprintBCD(int val,char dotPoint);
void LCDclr(void); //Clears LCD
void LCDhome(void); //LCD cursor home
void LCDcursorOn(void); //Underline cursor ON
void LCDcursorOnBlink(void); //Underline blinking cursor ON
void LCDcursorOFF(void); //Cursor OFF
void LCDblank(void); //LCD blank but not cleared
void LCDvisible(void); //LCD visible
// displays a horizontal progress bar at the current cursor location
// <progress> is the value the bargraph should indicate
// <maxprogress> is the value at the end of the bargraph
// <length> is the number of LCD characters that the bargraph should cover
//adapted from AVRLIB - displays progress only for 8 bit variables
void LCDprogressBar(uint8_t progress, uint8_t maxprogress, uint8_t length);
دیدگاه