TQ2440(ARM9)的第一个无OS实验【流水灯】
本文引用地址:https://www.eepw.com.cn/article/201611/318928.htm
- #include"2440addr.h"//包含2440相关寄存器的设置
- //四个LED对应GPB5.6.7.8
- #defineLED15
- #defineLED26
- #defineLED37
- #defineLED48
- #defineBit(x)(1<
- #defineOutput(x)(1<<2*x)//将对应IO置为输出
- /*******************************************
- *名称:Delay
- *功能:延时
- *入口参数:无
- *出口参数:无
- **********************************************/
- voidDelay()
- {
- inti,j,k;
- for(i=0;i<8;i++)
- {
- for(j=0;j<100;j++)
- {
- for(k=0;k<1000;k++);
- }
- }
- }
- /*******************************************
- *名称:Main
- *功能:测试流水灯功能
- *入口参数:无
- *出口参数:无
- **********************************************/
- voidMain(void)
- {
- inti;
- rGPBCON=(Output(LED1)|Output(LED2)|Output(LED3)|Output(LED4));//设置四个LED为输出
- while(1)
- {
- for(i=LED1;i<=LED4;i++)
- {
- rGPBDAT=~Bit(i);
- Delay();
- }
- }
- }
- 此后,可以直接下载至内存中执行,不过掉电后丢失;或者下载到NANDFlash中,上电后,s3c2440自动copyNANDFlsh前4K的代码到内存中,并从内存起始地址0x30000000开始执行程序。
- 0
评论