Getting Started

(lily) #1

Chapter 9 – Digital Meets Analog – ADC and DAC


once per millisecond
IGNAL(SIG_OUTPUT_COMPARE2)

+)


}


to HyperTerminal
{

for(int i = 0; i < signal; i++)

*********************************************************************************

*******

int dummy = 0;

// Take a dummy reading , which basically allows the ADC
l readings

// Interrupt occurs
S
{
int sig = 0;


sig = ADC_read();


if (tenth >= 10)
{
tenth = 0;
for(int i = 0; i < (sig/4); i+
{
sendChar(' ');
}
sendChar('*');
sendChar('\r');

/* // Test code to ou
if (tenth >= 10)


tput wave from table

tenth = 0;
signal /= 50;


{
sendChar(' ');
}
sendChar('');
sendChar('\r');
signal = 0;
}
/


}


/



  • ADC common functions

    */




void ADC_init()
{


ADMUX = 1;


// set ADC prescaler to , 1MHz / 8 = 125kHz
ADCSRA = (1<<ADEN) | (1<<ADPS1) | (1<<ADPS0);


// to hack up any hairballs before we take any rea
dummy = ADC_read();

Free download pdf