2014年2月3日 星期一

MCU Atmega128 LED閃爍燈

//FUNCTION : LED PORTA.0 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))
void main() {
Data_IO=0xFF; //8-LED DATA PORT IS OUT <1=OUT , 0=IN>
Data_DDR=0xFF;
Data_IO=0x00;
while(1)
{
SETBIT(PORTA,0);
Delay_ms(500);
CLRBIT(PORTA,0) ;
Delay_ms(500);
}
}

沒有留言:

張貼留言

Modbus FC=1 (Coils read) & FC=15 (Coils Write)

Modbus FC=1  (Coils read)  & FC=15 (Coils Write)   「從 Modbus 設備讀取多個線圈(Coils)狀態,並立刻將這些狀態原封不動地轉寫到另一個記憶體位址(起始位址 16)」 。 整個流程使用了知名套件 node-red...