Wednesday, 27 February 2008

Simple Idle Mode ( Mega ) ADC Example

The first ADC control example uses the Idle sleep mode and a simpledelay loop between samples, and the use of a pointer to write to theoutput array. The latter is hardly warranted in this case, but if theoutput array was two-dimensional it would make sense. Note the use of sbi/cbi instructions setting bits on PORTA. This is a very good debug tool if you have access to an oscilloscope.

//---------------------------------------------------------------------// Control the ADC for an eight channel sample using the inbuilt noise// cancelling capability.//void AtoDconverter(void){ sbi(PORTA, 1); // for scoping