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

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

168 CHAPTER 6. TIMING SUBSYSTEM<br />

//6.2% = 2 ms = 180 degrees = 16 counts<br />

//initiate PWM duty cycle variables<br />

PWM_duty_cycle = 12;<br />

OCR1BH = 0x00;<br />

OCR1BL = (unsigned char)(PWM_duty_cycle);<br />

//main activity loop - processor will continually cycle through loop for new<br />

//activity. Activity initialized by external signals presented to PORTB[1:0]<br />

while(1)<br />

{<br />

_StackCheck(); //check for stack overflow<br />

read_new_input();<br />

//read input status changes on PORTB<br />

}<br />

}//end main<br />

//Function definitions<br />

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

//power_on_reset:<br />

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

void power_on_reset(void)<br />

{<br />

initialize_ports(); //initialize ports<br />

}<br />

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

//initialize_ports: provides initial configuration for I/O ports<br />

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

void initialize_ports(void)<br />

{<br />

//PORTA<br />

DDRA=0xff; //PORTA[7:0] output<br />

PORTA=0x00; //Turn off pull ups

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

Saved successfully!

Ooh no, something went wrong!