Задача: АЦП помещает результаты преобразования в массив adc_data[].
Присваиваю переменной значение i-го элемента массива:
ind_press=adc_data[0];
И здесь CodeVision2,05 выдает ошибку Error: missing '('
Скобки вроде бы не должно быть. лепил ее во все места -не помогает.
Может эту операцию надо по другому выполнять?
Вся прога ниже:
Code
#include <mega16.h>
#include <spi.h>
#include <delay.h>
#include <stdio.h>
#asm // Alphanumeric LCD Module functions
.equ __lcd_port=0x12 ;PORTD
#endasm
#include <alcd.h>
//объявляю буфер данных жки
char lcd_buffer[33];
void lcd_show(void);
#define FIRST_ADC_INPUT 4
#define LAST_ADC_INPUT 7
unsigned char adc_data[LAST_ADC_INPUT-FIRST_ADC_INPUT+1];
#define ADC_VREF_TYPE 0x60 // 0110 0000 опорное AVcc
unsigned char ind_time;
unsigned char ind_naduv;
unsigned char ind_sduv;
unsigned char ind_press;
ind_press=adc_data[0]; //Error: missing '('
ind_naduv=adc_data[1];
ind_sduv=adc_data [2];
ind_time=adc_data [3];
// ADC interrupt service routine // with auto input scanning
interrupt [ADC_INT] void adc_isr(void)
{static unsigned char input_index=0;
// Read the 8 most significant bits
// of the AD conversion result
adc_data[input_index]=ADCH;
// Select next ADC input
if (++input_index > (LAST_ADC_INPUT-FIRST_ADC_INPUT))
input_index=0;
ADMUX=(FIRST_ADC_INPUT | (ADC_VREF_TYPE & 0xff))+input_index;
// Delay needed for the stabilization of the ADC input voltage
delay_us(10);}
void lcd_show(void)
{
//формирую строку
sprintf(lcd_buffer,"Press=%2i Time=%2i\nNaduv=%2i Sduv=%2i",ind_press,ind_time,ind_naduv,ind_sduv);
//в lcd_buffer помещается строка отформатированная так
//"Press=%2i Time=%2i\nNaduv=%2i Sduv=%2i",ind_press,ind_time,ind_naduv,ind_sduv
lcd_clear();
//вывожу эту строку
lcd_puts(lcd_buffer);
delay_ms(1000);
}
// External Interrupt 1 service routine
interrupt [EXT_INT1] void ext_int1_isr(void)
{}
// Timer 0 overflow interrupt service routine
interrupt [TIM0_OVF] void timer0_ovf_isr(void)
{}
// Timer1 output compare A interrupt service routine
interrupt [TIM1_COMPA] void timer1_compa_isr(void)
{}
// Timer2 overflow interrupt service routine
interrupt [TIM2_OVF] void timer2_ovf_isr(void)
{lcd_show();}
void main(void)
{PORTA=0x0E;
DDRA=0x01;
PORTB=0x01;
DDRB=0xFF;
PORTC=0xFF;
DDRC=0x00;
PORTD=0xFF;
DDRD=0xF7;
// Timer/Counter 0 initialization// Clock source: System Clock
// Clock value: 0,977 kHz// Mode: Normal top=0xFF// OC0 output: Disconnected
TCCR0=0x05;
TCNT0=0x00;
OCR0=0x00;
// Timer/Counter 1 initialization// Clock source: System Clock
// Clock value: 0,977 kHz// Mode: Normal top=0xFFFF
// OC1A output: Discon.// OC1B output: Discon.// Noise Canceler: Off
// Input Capture on Falling Edge// Timer1 Overflow Interrupt: Off
// Input Capture Interrupt: Off// Compare A Match Interrupt: On
// Compare B Match Interrupt: Off
TCCR1A=0x00;
TCCR1B=0x05;
TCNT1H=0x00;
TCNT1L=0x00;
ICR1H=0x00;
ICR1L=0x00;
OCR1AH=0x01;
OCR1AL=0xD1;
OCR1BH=0x00;
OCR1BL=0x00;
// Timer/Counter 2 initialization// Clock source: System Clock
// Clock value: 3,906 kHz// Mode: Normal top=0xFF// OC2 output: Disconnected
ASSR=0x00;
TCCR2=0x06;
TCNT2=0x00;
OCR2=0x00;
// External Interrupt(s) initialization// INT0: Off// INT1: On// INT1 Mode: Low level// INT2: Off
GICR|=0x80;
MCUCR=0x00;
MCUCSR=0x00;
GIFR=0x80;
// Timer(s)/Counter(s) Interrupt(s) initialization
TIMSK=0x51;
UCSRB=0x00;
ACSR=0x80;
SFIOR=0x00;
// ADC initialization// ADC Clock frequency: 250,000 kHz// ADC Voltage Reference: AREF pin
// ADC Auto Trigger Source: Timer0 Overflow// Only the 8 most significant bits of// the AD conversion result are used
ADMUX=FIRST_ADC_INPUT | (ADC_VREF_TYPE & 0xff);
ADCSRA=0xAA;
SFIOR&=0x1F;
SFIOR|=0x80; //1000 0000 запуск АЦП по переполнению Т0
// SPI initialization// SPI disabled
SPCR=0x00;
// TWI initialization// Bit Rate: 62,500 kHz
TWBR=0x00;
// Two Wire Bus Slave Address: 0x0// General Call Recognition: Off
TWAR=0x00;
// Generate Acknowledge Pulse: Off// TWI Interrupt: Off
TWCR=0x04;
TWSR=0x00;
// Characters/line: 16
lcd_init(16);
//вывожу заставку
lcd_clear();
lcd_gotoxy(3,0);
lcd_putsf("Pneumatic");
lcd_gotoxy(4,1);
lcd_putsf("massage");
// Global enable interrupts
#asm("sei")
while (1)
{}
}