21.08.2013 Views

Embedded Systems Design with the Atmel AVR Microcontroller Part II

Embedded Systems Design with the Atmel AVR Microcontroller Part II

Embedded Systems Design with the Atmel AVR Microcontroller Part II

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

258 CHAPTER 8. SYSTEM LEVEL DESIGN<br />

}<br />

//*************************************************************************<br />

void initialize_ports()<br />

{<br />

DDRD = 0xFB;<br />

DDRC = 0xFF;<br />

DDRB = 0xFF;<br />

}<br />

//*************************************************************************<br />

void initialize_ports()<br />

{<br />

DDRD = 0xFB;<br />

DDRC = 0xFF;<br />

DDRB = 0xFF;<br />

}<br />

//*************************************************************************<br />

void initialize_ADC()<br />

{<br />

ADMUX = 0; //Select channel 0<br />

//Enable ADC and set module enable ADC<br />

ADCSRA = 0xC3; //Set module prescalar to 8<br />

while(!(ADCSRA & 0x10)); //Wait until conversion is ready<br />

ADCSRA |= 0x10; //Clear conversion ready flag<br />

}<br />

//*************************************************************************<br />

unsigned int readADC(unsigned char channel)<br />

{

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!