求解ARM9实验箱UP2410里让GPC5,GPC6,GPC7实现流水灯。
程序代码:
#define GPCCON (*(volatile unsigned long *)0x56000020) #define GPCDAT (*(volatile unsigned long *)0x56000024) #define GPC5_OUT (1<<(5*2)) #define GPC6_OUT (1<<(6*2)) #define GPC7_OUT (1<<(7*2)) void wait (unsigned long ys) { for(;ys > 0;ys-- ); } int main(void) { unsigned long i = 0; GPCCON = GPC5_OUT|GPC6_OUT|GPC7_OUT; while(1) { wait(30000); GPCDAT = (~(i<<5)); if++i ==8) i = 0; } return 0; }
GPC5一直闪烁,还有如何实现GPC7,6,5倒着闪烁。