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

* 34630: 80c196kb 的奇怪现象,谢谢 !

   nust10 
nust10发表的帖子 

 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.


发表时间:2003年6月16日22:18:18

  
回复该帖

本主题共有 1 帖,分页:>>>>>该主题的所有内容[1]条

 *树形目录 只列出部分跟帖的标题以及简单的摘要信息 该主题的部分跟帖如下:

[上一篇帖子]:能说说是什么总线? 谢拉
[下一篇帖子]:你是不是说的LCD1330啊,如果是我有LCD1335的C51驱动,完全兼容的。