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.