2014年2月3日 星期一

MCU Atmega128 8個LED 閃爍燈

//************************************************************
//FUNCTION : 8 LED PORTA.0 -PORTA.7 FLASH
/* Test configuration:
MCU: ATmega128
Oscillator: External Clock 07.37280 MHz
Ext. Modules: -
SW: mikroC PRO for AVR
*/
//************************************************************
// Include Files
//************************************************************#define uchar unsigned char
#define uint unsigned int
#define Data_IO PORTA //8-LED DATA
#define Data_DDR DDRA //8-LED DATA DIRECTION
//----------------------------------------------------------------------------------------
// Macros
//----------------------------------------------------------------------------------------
#define SETBIT(ADDRESS,BIT) (ADDRESS |= (1<<BIT))
#define CLRBIT(ADDRESS,BIT) (ADDRESS &= ~(1<<BIT))
#define CHKBIT(ADDRESS,BIT) (ADDRESS & (1<<BIT))
char i;
void main() {
Data_IO=0xFF; //8-LED DATA PORT IS OUT <1=OUT , 0=IN>
Data_DDR=0xFF;
while(1)
{
Data_IO=0x01;
for (i=0 ; i<=7 ;i++)
{
Delay_ms(125);
Data_IO = Data_IO <<1;
}
Data_IO=0x80;
for (i=0 ; i<=7 ;i++)
{
Delay_ms(125);
Data_IO = Data_IO >>1;
}
}
}

沒有留言:

張貼留言

WOKWI DHT22 & LED , Node-Red + SQLite database

 WOKWI DHT22 & LED , Node-Red + SQLite database Node-Red程式 [{"id":"6f0240353e534bbd","type":"comment&...