导航: 老古网老古论坛XMOS公共讨论区XMOS开源项目区单片机程序设计嵌入式系统广告区域
→80c196kb 的奇怪现象,谢谢 ![nust10]

 *第13529篇: 80c196kb 的奇怪现象,谢谢 !

  
楼 主:nust10 2003年6月16日22:18
 80c196kb 的奇怪现象,谢谢 !
he CPU I use is 80c196KB 16, 8 bit data bus.
My problem is about writing an value to a memory-mapped I/O.  I define as the following:
#define  SBAUD  0xc0a
  
1. I write this code:
      *(unsigned char *)SBAUD=0x08;  
   It does'twork.  The value in I/O 0xc0a is 0x00,not 0x08.       

2. I write this code two times:
      *(unsigned char *)SBAUD=0x08;
      *(unsigned char *)SBAUD=0x08;
   It can work.  The value in I/O 0xc0a is 0x08.

3. If I write this code:
      *(unsigned char *)SBAUD=0x08;
      *(unsigned char *)SBAUD=0x08;
      *(unsigned char *)SBAUD=0x09;
   It works wrong. The value in I/O 0xc0a is 0x08,not 0x09.

4. If I write this code:
      *(unsigned char *)SBAUD=0x08;
      *(unsigned char *)SBAUD=0x08;
      *(unsigned char *)SBAUD=0x09;
      *(unsigned char *)SBAUD=0x09;
   It works well. The value in I/O 0xc0a is 0x09.

5. If I write this code:
      *(unsigned char *)SBAUD=0x08;
      *(unsigned char *)SBAUD=0x08;
      *(unsigned char *)SBAUD=0x09;
      *(unsigned char *)SBAUD=0x09;
      *(unsigned char *)SBAUD=0x0a;
   It works well. The value in I/O 0xc0a is 0x0a.

6. Another strange phenomenon is that if I add a unrelevant code before writing value to I/O :
     YcProcedure();
     *(unsigned char *)SBAUD=0x08;
   It works well. The value in I/O 0xc0a is 0x08. In fact, YcProcedure
function doesn't access I/O 0xc0a.

7. I can make sure that hardware is right. 
   The list file is explained as :
   54     2               *(unsigned char *)SBAUD =0x08;
          0076  B10B1C                       ldb     Tmp0,#08H
          0079  C7010A0C1C                   stb     Tmp0,0C0AH

*. I test to use volatile, still wrong.


>>>>>>对该主题发表你的看法

本主题贴数1,分页: [第1页]


[上一篇主题]:CY7C63723开发过东西,本人有一项目可委托

[下一篇主题]:单片机的串口没有CTS/RTS,如何控制流量呢