#include <iostm8.h>
#define _BV(A) (1<<(A))
//LED1 PD3
//LED2 PD2
//LED3 PD0
void delay(void)
{
volatile unsigned long i;
for(i=0;i<4000;i++);
}
void GPIO_Init(void)
{
PD_DDR = _BV(0)|_BV(2)|_BV(3);
PD_CR1 = _BV(0)|_BV(2)|_BV(3);
PD_CR2 = 0x00;
}
void CLK_Init(void)
{
CLK_CKDIVR &= ~0x10; /* 01: fHSI= fHSI RC output/2. */
CLK_CKDIVR |= 0x01; /* 001: fCPU=fMASTER/2. */
}
void main ( void )
{
CLK_Init();
GPIO_Init();
while(1)
{
PD_ODR=_BV(3);
delay();
PD_ODR=_BV(2);
delay();
PD_ODR=_BV(0);
delay();
}
} |