datasheet for ADC: http://www.cypress.com/?docID=40538 Среда разработки PSoC Disigner 5.3
Сделал так:
Код: Выделить всё
input_voltage = SAR6_VIN_cGetSample(); //return 6 bit number - signed from PORT
input_voltage = averaging_voltage(input_voltage);
char averaging_voltage( char voltage)
{
static char voltage_buffer[16];
char avv; //averaging voltage
int sum;
static unsigned char index = 0 ;
static unsigned char counter = 0 ;
unsigned char i;
voltage_buffer[index] = voltage;
index++;
index &= 0x0F;
for (i = 0; i < 16; i++)
{
if ((voltage_buffer[i] & 0x80) == 0x80)
{
sum -= ~voltage_buffer[i]+1;
}
else
{
sum += voltage_buffer[i];
}
}
avv =(char)sum >> 4; //16
avv = voltage;
return avv;
}


