This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Bug in simulation of virtual registors and their true port values

Hello!

Im using PK51 v9.05 for simulation poresess of external signal input.
Wrote script where time depended signal function change PORT3 pin state:

...
swatch (0.0250);
PORT3 ^= (1<<2);
swatch (0.0015);}
PORT3 |= (1<<2);
...

In analyzer window - I can see that correct signal, as PORT3 value,
but in program, when virtual PORT3, for ex. shows 0xFB value,
the real P3 always gives 0xFF .. Why, what did I wrong ?

PS: Strange, but some raroe time P3=PORT3 finally, not all time.

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

PPS: Beside, I marked, when Logic Analyzer is active and collect plenty of trace data, pressing of "Reset CPU" button totally crash Keil (v4.22) IDE. Annoying bug really

Parents
  • Hi Alex,

    please note that the virtual register PORTx and the SFR Px is not the same. The virtual register specifies the logic level at the pin and the SFR Px is the register that is read and written by the CPU. Since 8051 devices usually do not have a port direction register, the SFR Px defines the direction and the output value.
    Px.y = 0 -> active low output
    Px.y = 1 -> input or weak active high output
    Please see the users manual of your device for more details.

    If you write Px in your application, you write a new value into the Px register. If you read Px in your application, you read back the input values of the port, which is PORTx in the simulator. The Px value which you see in the peripherals dialogs is the value you have written into this register. Again, please see the users manual of your device for more details.

    So it is not unusual to see a P3 value of 0xff in the Port3 dialog when PORT3 is 0xFB. This means that all pins are inputs (P3 = 0xff) and the input value is 0xFB). If you read P3 in your application, you must see the value 0xFB.

    I cannot duplicate the uVision crash. I tried with our Measure example (C:\Keil\C51\Examples\Measure). Could you please send an example project which shows this issue to support.intl@keil.com? Then we will ananlyze and fix it.

    Regards,

    Hans

Reply
  • Hi Alex,

    please note that the virtual register PORTx and the SFR Px is not the same. The virtual register specifies the logic level at the pin and the SFR Px is the register that is read and written by the CPU. Since 8051 devices usually do not have a port direction register, the SFR Px defines the direction and the output value.
    Px.y = 0 -> active low output
    Px.y = 1 -> input or weak active high output
    Please see the users manual of your device for more details.

    If you write Px in your application, you write a new value into the Px register. If you read Px in your application, you read back the input values of the port, which is PORTx in the simulator. The Px value which you see in the peripherals dialogs is the value you have written into this register. Again, please see the users manual of your device for more details.

    So it is not unusual to see a P3 value of 0xff in the Port3 dialog when PORT3 is 0xFB. This means that all pins are inputs (P3 = 0xff) and the input value is 0xFB). If you read P3 in your application, you must see the value 0xFB.

    I cannot duplicate the uVision crash. I tried with our Measure example (C:\Keil\C51\Examples\Measure). Could you please send an example project which shows this issue to support.intl@keil.com? Then we will ananlyze and fix it.

    Regards,

    Hans

Children