Download Print this page

NEX ROBOTICS Fire Bird V ATMEGA2560 Software Manual page 54

Robotic research platform
Hide thumbs Also See for Fire Bird V ATMEGA2560:

Advertisement

NEX Robotics
unsigned char
port_restore = 0;
port_restore = PINC;
port_restore = port_restore & 0xF7;
PORTC = port_restore;
}
void
init_devices (void)
{
cli();
//Clears the global interrupts
port_init();
sei();
//Enables the global interrupts
}
//Main Function
int
main(void)
{
init_devices();
while(1)
{
buzzer_on();
_delay_ms(1000);
buzzer_off();
_delay_ms(1000);
}
}
In this code, first three lines represent the header file declaration. The # include directive is used
for including header files in the existing code. The syntax for writing header file is as follows:
#include
<avr/io.h>
This # include directive will add the already existing io.h header file stored in avr folder under
WinAVR folder. The same way other header files are also included in the main program so that
we can use various utilities defined in the header files.
In all the codes we will configure pins related to any particular module in the xxxx_pin_config()
functions. In this example code we have used the function buzzer_pin_config(). Buzzer is
connected to the PORTC 3 pin of the microcontroller. PORTC 3 is configured as output with the
initial value set to logic 0 to keep buzzer off at the time of port initialization. All the
xxxx_pin_config() functions will be initialized in the port_init() function in all the codes as a
convention. Function init_devices() will be used to initialize all the peripherals of the
microcontroller as a convention.
In the above code buzzer is turned on by calling function buzzer_on().
_delay_ms(1000) introduces delay of 1 second.
Buzzer is turned off by calling function buzzer_off().
Again _delay_ms(1000) introduces delay of 1 second.
All these statements are written in while(1) loop construct to make buzzer on-off periodically.
www.nex-robotics.com
Fire Bird V Software Manual
//delay
//delay
54

Advertisement

loading
Need help?

Need help?

Do you have a question about the Fire Bird V ATMEGA2560 and is the answer not in the manual?