Вы находитесь на странице: 1из 3

/***************************************************** This program was produced by the CodeWizardAVR V2.05.

1b Evaluation Automatic Program Generator Copyright 1998-2011 Pavel Haiduc, HP InfoTech s.r.l. http://www.hpinfotech.com Project : Version : Date : 7/7/2011 Author : Freeware, for evaluation and non-commercial use only Company : Comments: Chip type : ATmega16 Program type : Application AVR Core Clock frequency: 8.000000 MHz Memory model : Small External RAM size : 0 Data Stack size : 256 *****************************************************/ #include <mega16.h> #include <delay.h> // Standard Input/Output functions #include <stdio.h> #define ADC_VREF_TYPE 0x20 // Read the 8 most significant bits // of the AD conversion result unsigned char read_adc(unsigned char adc_input) { ADMUX=adc_input (ADC_VREF_TYPE & 0xff); // Delay needed for the stabilization of the ADC input voltage delay_us(10); // Start the AD conversion ADCSRA =0x40; // Wait for the AD conversion to complete while ((ADCSRA & 0x10)==0); ADCSRA =0x10; return ADCH; } // Declare your global variables here void main(void) { // Declare your local variables here int i,j; int c[32][32]; int a[32]={0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0A,0x0B,0x0 C,0x0D,0x0F,0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17,0x18,0x19,0x1A,0x1B,0x1C,0x1 D,0x1F}; // Input/Output Ports initialization // Port A initialization

// Func7=In Func6=In Func5=In Func4=In Func3=In Func2=In Func1=In Func0=In // State7=T State6=T State5=T State4=T State3=T State2=T State1=T State0=T PORTA=0x00; DDRA=0x80; // Port B initialization // Func7=Out Func6=Out Func5=Out Func4=Out Func3=Out Func2=Out Func1=Out Func0=O ut // State7=0 State6=0 State5=0 State4=0 State3=0 State2=0 State1=0 State0=0 PORTB=0x00; DDRB=0xFF; // Port C initialization // Func7=Out Func6=Out Func5=Out Func4=Out Func3=Out Func2=Out Func1=Out Func0=O ut // State7=0 State6=0 State5=0 State4=0 State3=0 State2=0 State1=0 State0=0 PORTC=0x00; DDRC=0xFF; // Port D initialization // Func7=In Func6=In Func5=In Func4=In Func3=In Func2=In Func1=In Func0=In // State7=T State6=T State5=T State4=T State3=T State2=T State1=T State0=T PORTD=0x00; DDRD=0x00; // USART initialization // Communication Parameters: 8 Data, 1 Stop, No Parity // USART Receiver: On // USART Transmitter: On // USART Mode: Asynchronous // USART Baud Rate: 9600 UCSRA=0x00; UCSRB=0x18; UCSRC=0x86; UBRRH=0x00; UBRRL=0x33; // ADC initialization // ADC Clock frequency: 1000.000 kHz // ADC Voltage Reference: AREF pin // ADC Auto Trigger Source: Free Running // Only the 8 most significant bits of // the AD conversion result are used ADMUX=ADC_VREF_TYPE & 0xff; ADCSRA=0xA3; SFIOR&=0x1F; while (1) { // Place your code here for(i=0;i<32;i++) { PORTA.7=1; PORTC=a[i]; PORTA.7=1; PORTB=0x00; PORTA.7=0; c[i][0]=read_adc(0); c[i][1]=read_adc(1); j=2; while(j<32)

{ PORTA.7=1; PORTB=PORTB+1; PORTA.7=0; delay_us(1); c[i][j]=read_adc(0); j++; c[i][j]=read_adc(1); j++; } }

for(i=0;i<32;i++) { for(j=0;j<32;j++) {printf("%d,\t",&c[i][j]); } printf(";"); } } }

Вам также может понравиться