Chinaunix首页 | 论坛 | 博客
  • 博客访问: 13548
  • 博文数量: 10
  • 博客积分: 275
  • 博客等级: 二等列兵
  • 技术积分: 110
  • 用 户 组: 普通用户
  • 注册时间: 2011-07-04 16:18
文章分类
文章存档

2011年(10)

我的朋友

分类: 嵌入式

2011-07-05 16:31:56

实验目的: 串口回显程序
实验环境: mini2440(arm920t)串口工具(超级终端)
工具: ads1.2 h-jtag1.0 
步骤:
1.在ads中新建led工程,添加文件init.s main.c如下
init.s
  1.     area init,code,readonly
  2. start
  3.     ldr sp,=4096
  4.     import main
  5.     bl main
  6.     end
main.c
  1. #define rGPHCON     (*((volatile unsigned *)0x56000070))
  2. #define rGPHDAT     (*((volatile unsigned *)0x56000074))

  3. #define rULCON0     (*((volatile unsigned *)0x50000000))
  4. #define rUCON0      (*((volatile unsigned *)0x50000004))    
  5. #define rUFCON0     (*((volatile unsigned *)0x50000008))
  6. #define rUMCON0     (*((volatile unsigned *)0x5000000c))    
  7. #define rUBRDIV0    (*((volatile unsigned *)0x50000028))

  8. #define rUTXH0      (*((volatile unsigned *)0x50000020))
  9. #define rURXH0      (*((volatile unsigned *)0x50000024))
  10. #define rUTRSTAT0   (*((volatile unsigned *)0x50000010))

  11. int main()
  12. {
  13.     rGPHCON |= 0xa0;
  14.     rULCON0 = 0x3;
  15.     rUCON0 = 0x5;
  16.     rUFCON0 = 0x0;
  17.     rUMCON0 = 0x0;
  18.     rUBRDIV0 = 18;
  19.     
  20.     while(1)
  21.     {
  22.         while(!(rUTRSTAT0 & 0x1));
  23.         while(!(rUTRSTAT0 & 1<<2));
  24.         rUTXH0 = rURXH0;
  25.     }
  26.     return 0;
  27. }
2.ADS AXD H-JTAG的配置同led程序。超级终端设置 115200 8 n 1 无。
备注:
    rUTXH0,rURXH0的地址要视大小端情况,刚才开始没注意到一直使用的大端的地址。光盘的示例程序中有2440addr.h文件,可以查找各寄存器的地址。
阅读(346) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~