donderdag 31 januari 2013
Simple XMEGA 128A4U ledblink
/*
* Microcontroller_Project.c
*
* Created: 1/31/2013 5:59:45 PM
* Author: CALX2
*/
#include avr/io.h
#include util/delay.h
#define BLINK_DELAY_MS 1000 //set delay 1000 ms (1second) declared here
int main(void)
{
PORTC_DIRSET = PIN0_bm; //set PIN0 of PORTC output
PORTB_DIRSET = PIN1_bm; //set PIN1 of PORTB output
PORTE_DIRSET = PIN0_bm; //set PIN0 of PORTC output (LED on board)
while(1) //forever loop
{
PORTC_OUTSET = PIN0_bm ; // set output high
_delay_ms(BLINK_DELAY_MS) ;
PORTC_OUTCLR = PIN0_bm ; // set output low
_delay_ms(BLINK_DELAY_MS) ;
PORTB_OUTSET = PIN1_bm ; //set output high
_delay_ms(BLINK_DELAY_MS) ;
PORTB_OUTCLR = PIN1_bm ; //set output low
_delay_ms(BLINK_DELAY_MS) ;
if(PORTC_OUTSET = 1) //if PORTC output high
{
PORTE_OUTTGL = PIN0_bm; //TGGLE PIN0 of PORTE
}
}
}
Abonneren op:
Posts (Atom)