主题 : 裸机依次点亮LED烧到板内四支灯常亮,请求点拨! 复制链接 | 浏览器收藏 | 打印
级别: 新手上路
UID: 32609
精华: 0
发帖: 13
金钱: 65 两
威望: 13 点
综合积分: 26 分
注册时间: 2010-11-18
最后登录: 2017-09-13
楼主  发表于: 2011-05-25 10:36

 裸机依次点亮LED烧到板内四支灯常亮,请求点拨!

烧到板内的文件的源代码
crt0.s:
复制代码
  1. .text
  2. .global _start
  3. _start: 
  4.           ldr         r0, =0x53000000 
  5.           mov      r1, #0x0 
  6.           str         r1, [r0]                             @disabled the watchdog 
  7.   
  8.           ldr         sp, =4096                      @init the stack 
  9.           bl          main                               @call main function
  10. halt_loop: 
  11.           b          halt_loop


main.c
复制代码
  1. #define GPBCON (*(volatile unsigned long *)0x56000010)
  2. #define GPBDAT (*(volatile unsigned long *)0x56000014)
  3. #define GPB5OUT (1<<10)
  4. #define GPB6OUT (1<<12)
  5. #define GPB7OUT (1<<14)
  6. #define GPB8OUT (1<<16)
  7. void delay(volatile unsigned long t)
  8.           unsigned int i; 
  9.           while(t--) 
  10.           { 
  11.                    i = 400; 
  12.                   while(i!=0) 
  13.                   { 
  14.                               i--;   
  15.                   } 
  16.    
  17.           }
  18. }
  19. int main(void)
  20.           unsigned long j = 8; 
  21.           GPBCON = GPB5OUT | GPB6OUT | GPB7OUT | GPB8OUT;  
  22.           while(1) 
  23.           { 
  24.                   GPBDAT = ~(1<<j); 
  25.                   delay(10000); 
  26.                   GPBDAT |= (1<<j); 
  27.                   delay(10000); 
  28.                   if(++j >= 9) 
  29.                   { 
  30.                            j = 5; 
  31.                   } 
  32.           } 
  33.                    return 0;
  34. }