免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 727 | 回复: 0
打印 上一主题 下一主题

mini2440 led 实验 (一) [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2011-12-22 08:51 |只看该作者 |倒序浏览
实验目的: led跑马灯程序
实验环境: mini2440(arm920t)
工具: ads1.2 h-jtag1.0 
步骤:
1.在ads中新建led工程,添加文件init.s main.c如下
init.s    
  1.     area init,code,readonly
  2.     import main
  3. start
  4.     ldr sp,=4096
  5.     bl main
  6.     end
main.c
  1. #define rGPBCON (*((volatile unsigned *)0x56000010))
  2. #define rGPBDATA (*((volatile unsigned *)0x56000014))
  3. #define LED1_ON rGPBDATA &=(~(1<<5))
  4. #define LED2_ON rGPBDATA &=(~(1<<6))
  5. #define LED3_ON rGPBDATA &=(~(1<<7))
  6. #define LED4_ON rGPBDATA &=(~(1<<8))
  7. #define LED1_OFF rGPBDATA |=(1<<5)
  8. #define LED2_OFF rGPBDATA |=(1<<6)
  9. #define LED3_OFF rGPBDATA |=(1<<7)
  10. #define LED4_OFF rGPBDATA |=(1<<8)
  11. void delay(int i)
  12. {
  13.     while(i--);
  14. }
  15. int main()
  16. {
  17.     rGPBCON = 0x15400;
  18.     while(1)
  19.     {
  20.         LED1_ON;
  21.         delay(100000);
  22.         LED2_ON;
  23.         delay(100000);
  24.         LED3_ON;
  25.         delay(100000);
  26.         LED4_ON;
  27.         delay(100000);
  28.         LED1_OFF;
  29.         delay(100000);
  30.         LED2_OFF;
  31.         delay(100000);
  32.         LED3_OFF;
  33.         delay(100000);
  34.         LED4_OFF;
  35.         delay(100000);
  36.     }
  37. return 0;
  38. }
2.设置工程
    post-linker : ARM fromELF
    ARM Assembler/ARM C Compiler : ARM902T
    ARM Linker -> Output -> RO Base : 0x30000000
               -> Options -> Image entry point : 0x30000000
               -> Layout -> Object/Symbol : init.o
                         -> Section : init
3.h-jtag添加init script : init -> init script -> load "FriendlyARM2440.his"(光盘h-jtag目录下)
4.AXD设置
   第一次使用AXD时,需要options -> configure target -> add H-JTAG.dll (h-jtag安装目录下)

备注:
   从nor启动时程序能正确运行。从nand启动时看不到跑马灯效果,但是单步运行发现程序正常,可能2种情况执行速度有差别。
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP