chương trình trước đây bị lỗi nhưng giờ biên dịch lại không được? trong đó lỗi tại dòng khai báo "int KP,KI,KD" khi bỏ dòng này thì biên dịch được. chỉ bị lỗi khi chuỷen sang ASM.
nó báo:error(s) occured duỉng assembly.
chương trình như sau:
/************************************************** ***
This program was produced by the
CodeWizardAVR V1.25.9 Professional
Automatic Program Generator
© Copyright 1998-2008 Pavel Haiduc, HP InfoTech s.r.l.
http://www.hpinfotech.com
Project :
Version :
Date : 8/7/2008
Author : F4CG
Company : F4CG
Comments:
Chip type : ATmega8
Program type : Application
Clock frequency : 8.000000 MHz
Memory model : Small
External SRAM size : 0
Data Stack size : 256
************************************************** ***/
#include <mega8.h>
#include <delay.h>
#include <stdio.h>
/************************************************** *****/
char LINE = 0,LINE_PRE = 0,scan_key_flag = 1;
long int error_0,error_1,error_2;
int KP,KD,KI; //khi bỏ dòng này thì biên dịch thành công
#pragma warn-
eeprom int set_point;
eeprom int Kp,Kd,Ki;
#pragma warn+
#define UP_BUTTON_ON PINC.3==0
#define UP_BUTTON_OFF PINC.3==1
#define DOWN_BUTTON_ON PINC.5==0
#define DOWN_BUTTON_OFF PINC.5==1
#define RIGHT_BUTTON_ON PINC.2==0
#define RIGHT_BUTTON_OFF PINC.2==1
#define LEFT_BUTTON_ON PINC.4==0
#define LEFT_BUTTON_OFF PINC.4==1
#define BUZZER_ON PORTB.2 = 1
#define BUZZER_OFF PORTB.2 = 0
#define OUTPUT_ON PORTB.1 = 0
#define OUTPUT_OFF PORTB.1 = 1
#define READ_TEMPERATURE read_adc(1)
#define T_BZZR_ON delay_ms(30)
#define T_BZZR_OFF delay_ms(100)
#define XY lcd_gotoxy
#define STRING lcd_putsf
#define CHAR lcd_putchar
#define CLRSCR lcd_clear()
#define POSITIVE 1
#define NEGATIVE 0
#define T_CYCLE_PID 20000
#define T_CYCLE_DISPLAY 2000
/************************************************** ***/
void run(void);
void setting(void);
void bintobcd(long int value,char x,char y);
/************************************************** ***/
// Alphanumeric LCD Module functions
#asm
.equ __lcd_port=0x12 ;PORTD
#endasm
#include <lcd.h>
// Timer 1 overflow interrupt service routine
interrupt [TIM1_OVF] void timer1_ovf_isr(void)
{
// Place your code here
}
#include <delay.h>
#define ADC_VREF_TYPE 0x00
// ADC interrupt service routine
interrupt [ADC_INT] void adc_isr(void)
{
unsigned int adc_data;
// Read the AD conversion result
adc_data=ADCW;
// Place your code here
}
// Declare your global variables here
void main(void)
{
// Declare your local variables here
// Input/Output Ports initialization
// Port B initialization
// Func7=In Func6=In Func5=In Func4=In Func3=In Func2=Out Func1=Out Func0=In
// State7=P State6=P State5=P State4=P State3=P State2=1 State1=1 State0=P
PORTB=0xFF;
DDRB=0x06;
// Port C initialization
// Func6=In Func5=In Func4=In Func3=In Func2=In Func1=In Func0=In
// State6=P State5=P State4=P State3=P State2=P State1=P State0=P
PORTC=0x7F;
DDRC=0x00;
// Port D initialization
// Func7=Out Func6=Out Func5=Out Func4=Out Func3=Out Func2=Out Func1=Out Func0=Out
// State7=1 State6=1 State5=1 State4=1 State3=1 State2=1 State1=1 State0=1
PORTD=0xFF;
DDRD=0xFF;
// Timer/Counter 0 initialization
// Clock source: System Clock
// Clock value: Timer 0 Stopped
TCCR0=0x00;
TCNT0=0x00;
// Timer/Counter 1 initialization
// Clock source: System Clock
// Clock value: 125.000 kHz
// Mode: Normal top=FFFFh
// OC1A output: Discon.
// OC1B output: Discon.
// Noise Canceler: Off
// Input Capture on Falling Edge
// Timer 1 Overflow Interrupt: On
// Input Capture Interrupt: Off
// Compare A Match Interrupt: Off
// Compare B Match Interrupt: Off
TCCR1A=0x00;
TCCR1B=0x03;
TCNT1H=0x00;
TCNT1L=0x00;
ICR1H=0x00;
ICR1L=0x00;
OCR1AH=0x00;
OCR1AL=0x00;
OCR1BH=0x00;
OCR1BL=0x00;
// Timer/Counter 2 initialization
// Clock source: System Clock
// Clock value: Timer 2 Stopped
// Mode: Normal top=FFh
// OC2 output: Disconnected
ASSR=0x00;
TCCR2=0x00;
TCNT2=0x00;
OCR2=0x00;
// External Interrupt(s) initialization
// INT0: Off
// INT1: Off
MCUCR=0x00;
// Timer(s)/Counter(s) Interrupt(s) initialization
TIMSK=0x04;
// Analog Comparator initialization
// Analog Comparator: Off
// Analog Comparator Input Capture by Timer/Counter 1: Off
ACSR=0x80;
SFIOR=0x00;
// ADC initialization
// ADC Clock frequency: 1000.000 kHz
// ADC Voltage Reference: AREF pin
ADMUX=ADC_VREF_TYPE & 0xff;
ADCSRA=0x8B;
// LCD module initialization
lcd_init(16);
// Global enable interrupts
#asm("sei")
while (1)
{
// Place your code here
};
}
////////////////mong các bạn chỉ giúp.
nó báo:error(s) occured duỉng assembly.
chương trình như sau:
/************************************************** ***
This program was produced by the
CodeWizardAVR V1.25.9 Professional
Automatic Program Generator
© Copyright 1998-2008 Pavel Haiduc, HP InfoTech s.r.l.
http://www.hpinfotech.com
Project :
Version :
Date : 8/7/2008
Author : F4CG
Company : F4CG
Comments:
Chip type : ATmega8
Program type : Application
Clock frequency : 8.000000 MHz
Memory model : Small
External SRAM size : 0
Data Stack size : 256
************************************************** ***/
#include <mega8.h>
#include <delay.h>
#include <stdio.h>
/************************************************** *****/
char LINE = 0,LINE_PRE = 0,scan_key_flag = 1;
long int error_0,error_1,error_2;
int KP,KD,KI; //khi bỏ dòng này thì biên dịch thành công
#pragma warn-
eeprom int set_point;
eeprom int Kp,Kd,Ki;
#pragma warn+
#define UP_BUTTON_ON PINC.3==0
#define UP_BUTTON_OFF PINC.3==1
#define DOWN_BUTTON_ON PINC.5==0
#define DOWN_BUTTON_OFF PINC.5==1
#define RIGHT_BUTTON_ON PINC.2==0
#define RIGHT_BUTTON_OFF PINC.2==1
#define LEFT_BUTTON_ON PINC.4==0
#define LEFT_BUTTON_OFF PINC.4==1
#define BUZZER_ON PORTB.2 = 1
#define BUZZER_OFF PORTB.2 = 0
#define OUTPUT_ON PORTB.1 = 0
#define OUTPUT_OFF PORTB.1 = 1
#define READ_TEMPERATURE read_adc(1)
#define T_BZZR_ON delay_ms(30)
#define T_BZZR_OFF delay_ms(100)
#define XY lcd_gotoxy
#define STRING lcd_putsf
#define CHAR lcd_putchar
#define CLRSCR lcd_clear()
#define POSITIVE 1
#define NEGATIVE 0
#define T_CYCLE_PID 20000
#define T_CYCLE_DISPLAY 2000
/************************************************** ***/
void run(void);
void setting(void);
void bintobcd(long int value,char x,char y);
/************************************************** ***/
// Alphanumeric LCD Module functions
#asm
.equ __lcd_port=0x12 ;PORTD
#endasm
#include <lcd.h>
// Timer 1 overflow interrupt service routine
interrupt [TIM1_OVF] void timer1_ovf_isr(void)
{
// Place your code here
}
#include <delay.h>
#define ADC_VREF_TYPE 0x00
// ADC interrupt service routine
interrupt [ADC_INT] void adc_isr(void)
{
unsigned int adc_data;
// Read the AD conversion result
adc_data=ADCW;
// Place your code here
}
// Declare your global variables here
void main(void)
{
// Declare your local variables here
// Input/Output Ports initialization
// Port B initialization
// Func7=In Func6=In Func5=In Func4=In Func3=In Func2=Out Func1=Out Func0=In
// State7=P State6=P State5=P State4=P State3=P State2=1 State1=1 State0=P
PORTB=0xFF;
DDRB=0x06;
// Port C initialization
// Func6=In Func5=In Func4=In Func3=In Func2=In Func1=In Func0=In
// State6=P State5=P State4=P State3=P State2=P State1=P State0=P
PORTC=0x7F;
DDRC=0x00;
// Port D initialization
// Func7=Out Func6=Out Func5=Out Func4=Out Func3=Out Func2=Out Func1=Out Func0=Out
// State7=1 State6=1 State5=1 State4=1 State3=1 State2=1 State1=1 State0=1
PORTD=0xFF;
DDRD=0xFF;
// Timer/Counter 0 initialization
// Clock source: System Clock
// Clock value: Timer 0 Stopped
TCCR0=0x00;
TCNT0=0x00;
// Timer/Counter 1 initialization
// Clock source: System Clock
// Clock value: 125.000 kHz
// Mode: Normal top=FFFFh
// OC1A output: Discon.
// OC1B output: Discon.
// Noise Canceler: Off
// Input Capture on Falling Edge
// Timer 1 Overflow Interrupt: On
// Input Capture Interrupt: Off
// Compare A Match Interrupt: Off
// Compare B Match Interrupt: Off
TCCR1A=0x00;
TCCR1B=0x03;
TCNT1H=0x00;
TCNT1L=0x00;
ICR1H=0x00;
ICR1L=0x00;
OCR1AH=0x00;
OCR1AL=0x00;
OCR1BH=0x00;
OCR1BL=0x00;
// Timer/Counter 2 initialization
// Clock source: System Clock
// Clock value: Timer 2 Stopped
// Mode: Normal top=FFh
// OC2 output: Disconnected
ASSR=0x00;
TCCR2=0x00;
TCNT2=0x00;
OCR2=0x00;
// External Interrupt(s) initialization
// INT0: Off
// INT1: Off
MCUCR=0x00;
// Timer(s)/Counter(s) Interrupt(s) initialization
TIMSK=0x04;
// Analog Comparator initialization
// Analog Comparator: Off
// Analog Comparator Input Capture by Timer/Counter 1: Off
ACSR=0x80;
SFIOR=0x00;
// ADC initialization
// ADC Clock frequency: 1000.000 kHz
// ADC Voltage Reference: AREF pin
ADMUX=ADC_VREF_TYPE & 0xff;
ADCSRA=0x8B;
// LCD module initialization
lcd_init(16);
// Global enable interrupts
#asm("sei")
while (1)
{
// Place your code here
};
}
////////////////mong các bạn chỉ giúp.
Comment