1. 程式人生 > >S3c2440裸機程式【1】跑馬燈

S3c2440裸機程式【1】跑馬燈

由JZ2440v2原理圖可知:

nLED1--->GPF4,nLED2--->GPF5nLED3--->GPF6


S3C2440晶片手冊關於IO口配置:



程式程式碼:

#define	GPFCON		(*(volatile unsigned long *)0x56000050)
#define	GPFDAT		(*(volatile unsigned long *)0x56000054)

#define Led1_On      ~(1<<4)
#define Led1_Off      (1<<4)
#define Led2_On      ~(1<<5)
#define Led2_Off      (1<<5)
#define Led3_On      ~(1<<6)
#define Led3_Off      (1<<6)

void Led_Port_Init(void);
void delay(int i);

int main(void)
{
	Led_Port_Init();
	while(1)
	{
		GPFDAT &= Led1_On;
		delay(10000);
		GPFDAT |= Led1_Off;
		delay(10000);
		
		GPFDAT &= Led2_On;
		delay(10000);
		GPFDAT |= Led2_Off;
		delay(10000);
		
		GPFDAT &= Led3_On;
		delay(10000);
		GPFDAT |= Led3_Off;
		delay(10000);
	}
	return 0;
}

void Led_Port_Init(void)
{
	GPFCON = (1<<(2*4))|(1<<(2*5))|(1<<(2*6));
}

void delay(int t)
{
	int a,b;
	for(a=0;a<t;a++)
		for(b=0;b<100;b++);
}


注意,需要在S3C2440.s檔案中配置埠為輸出埠。