Chinaunix首页 | 论坛 | 博客
  • 博客访问: 681592
  • 博文数量: 85
  • 博客积分: 1797
  • 博客等级: 上尉
  • 技术积分: 1238
  • 用 户 组: 普通用户
  • 注册时间: 2007-12-02 08:53
个人简介

职位:技术总监 1、精通c++(linux平台、vc++Mfc、qt)、java、php、unity3d,略懂python 2、用c++开发过嵌入式产品,用c++开发过大型银行运维产品 3、用java开发大型银行运维产品,学校教务系统 4、用php开发进销存系统(在销售中),用php开发淘宝小程序 5、用unity3d开发衣柜设计软件,在运营中

文章分类

全部博文(85)

分类: 嵌入式

2011-09-21 22:10:24

①串口的编程很简单,设置好四个引脚就好了

  1. rPCONE |= (2<<2)|(2<<4); //rxd txd

  2.            //rPCONE |= (0x01<<2)|(0x01<<4); //rxd txd 第一次竟然写成了这个

  3.            rPDATG &= ~BIT1; //RTS 为0请求接收;

  4.            rPCONG |= (1<<2);


这样串口就能通讯了

②中断方式发送数据
    设置要点:串口寄存器,中断寄存器,中断函数

  1. rULCON0=0x3; //Normal,No parity,1 stop,8 bit

  2.     rUCON0=0x045; //0000,0100,0101。rx=edge,tx=level,disable timeout int.,enable rx error int.,normal,interrupt or polling


  3. Uart_Printf("\nTest begin:!");
  4. uart0TxStr="UART0 Tx interrupt test is good!!!!\r\n";

  5. pISR_UTXD0 = (unsigned)Uart0_TxInt;
  6. rINTCON = 0;
  7. rINTMSK =~ (BIT_GLOBAL|BIT_UTXD0);
  8. rINTMOD = 0;

 

③DMA方式发送数据
    设置要点:串口寄存器,DMA寄存器

  1. rUCON0 = 0x245; //for BDMA0


  2. Uart_Printf("\n[Uart0 Tx Test by BDMA0]\n");
  3. uart0TxStr="UART0 Tx Test by BDMA0 is good!!!!\r\n";
  4. //Uart_TxEmpty(0);


  5. rUCON0=0x48; //tx:BDMA0 rx:disable


  6. rBDICNT0=0x0;
  7. rBDCON0 =0x0;
  8. rBDISRC0=(unsigned int)uart0TxStr|(0<<30)|(1<<28); // byte,inc

  9. rBDIDES0=UTXH0 |(1<<30)|(3<<28); //L/B endian,M2IO,fix

  10. rBDICNT0=strlen((char *)uart0TxStr)|(2<<30)|(1<<26)|(0<<20); //UART0,

  11. rBDICNT0 |= (1<<20); //enable

  12. rBDCON0 = (0x0<<2);

              

阅读(3383) | 评论(1) | 转发(2) |
给主人留下些什么吧!~~

2011-09-28 19:50:22

http://www.bags2world.com/