thannara123
Advanced Member level 5
I am making a simple project with Attiny13
Trying to read ADC value while making program am getting Error as follows
Error 1 in extract_insn, at recog.c:2109
Error 2 unrecognizable insn:
It shows whenever i return the Unint16 value from a float value Pleas see the program .
The error will goes when i will give a random value to the variable temp just before the return in the test function.</adc_value)
</adsc));
</adsc);></avr></avr>
Trying to read ADC value while making program am getting Error as follows
Error 1 in extract_insn, at recog.c:2109
Error 2 unrecognizable insn:
It shows whenever i return the Unint16 value from a float value Pleas see the program .
Code:
#include <avr/io.h>
#include <avr/interrupt.h>
#define F_CPU 9600000
void adc_init()
{
ADMUX=0x00; // VCC used as voltage referance
ADMUX |= (1 << MUX0); //// Set the ADC input to PB2/ADC1
ADCSRA |= (1 << ADPS1) | (1 << ADPS0) | (1 << ADEN);//Set the prescaler to clock/128 & enable ADC
}
unsigned int read_adc()
{ unsigned int LSB_data=0,MSB_data =0, adc_value=0;
ADMUX |= (1 << MUX0);
ADCSRA|=(1<<ADSC); // start conversion
while(ADCSRA & (1<<ADSC));
LSB_data = ADCL ;
MSB_data = ADCH ;
adc_value = ((unsigned int)MSB_data<<8);
adc_value = adc_value |((unsigned int)LSB_data);
return (adc_value);
}
int test()
{
int i,adc_value[100]={0}; uint16_t temp =0;
adc_init();
for(i=0; i<100;i++) // samples taking from 41 times 9.4milli second taken about on complte half cycle
{
adc_value[i] = read_adc(); // reading voltage
}
temp = adc_value[0];
for(i=0; i<100; i++)
{
if(temp<adc_value[i])
temp= adc_value[i];
}
// temp =100;
return (temp);//*(0.639)); //o making Peak to RMS
}
int main(void)
{
uint16_t adc_value1=0;
adc_value1 = test();
while(1)
{
//TODO:: Please write your application code
}
}
<avr io.h=""><avr interrupt.h=""><adsc); start="" conversion
<adsc));
<adc_value[i])
The error will goes when i will give a random value to the variable temp just before the return in the test function.</adc_value)
</adsc));
</adsc);></avr></avr>
Last edited: