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

Simulates and emulates bug free

I got my program to a point where I needed to test so I ran it in the uVision simulator. It was flawless. I fired up my Nohau emulator and ran it on our new PC board. Perfect.

I burned a chip (89C51RD2) and popped it in the board...nothing.

Since I am now the only embedded guy in the shop I work alone I have no one to bounce ideas off. So I've come here.

The oscilloscope shows that timer_0 is running, and my ISR is OK because the watchdog strobe is happening and the timer values are being reloaded.

Has anyone seen this before? Do you have a suggestion of of path to find the differences between the simulated and emulated situation and running on the board?

Parents
  • I expected it to send an "I'Alive" packet out the serial port, a heartbeat LED to pulse and flipping dipswitches to turn ports ON/OFF.

    The code in its current state turns P2^0 through P2^7 ON/OFF based on the state of the dipswitch located at P0^0 through P0^7. I have LEDs on the TX, RX and DIR lines (its RS-485) and a "heartbeat" LED that I strobe every 500 mSecs. In the simulator the simulated LEDs work appropriately and P2 changes as expected. Using the emulator the LEDs flash, I catch the message on my development system and the 'scope shows the changing of P2 with P0. On the board the LEDs do not flash, the heartbeat does not flash and P2 does not change.

    The heartbeat is in my main loop and it watches a variable that is undated in the timer_0 ISR. When it reaches the target value I toggle the state of the heartbeat LED and reset the variable.

    The serial "stuff" is code that I include in almost all of my projects and probably fairly common RS-485 stuff with the exception that it supports our proprietary protocol. I don't think I've made a change to any of that code in over 5 years.

    My normal operating mode is to get the code for new boards to the communications, heartbeat and test port point and then begin to test the actual board. I'm reasonably confident that the board is functioning as expected since the code works in the emulator.

Reply
  • I expected it to send an "I'Alive" packet out the serial port, a heartbeat LED to pulse and flipping dipswitches to turn ports ON/OFF.

    The code in its current state turns P2^0 through P2^7 ON/OFF based on the state of the dipswitch located at P0^0 through P0^7. I have LEDs on the TX, RX and DIR lines (its RS-485) and a "heartbeat" LED that I strobe every 500 mSecs. In the simulator the simulated LEDs work appropriately and P2 changes as expected. Using the emulator the LEDs flash, I catch the message on my development system and the 'scope shows the changing of P2 with P0. On the board the LEDs do not flash, the heartbeat does not flash and P2 does not change.

    The heartbeat is in my main loop and it watches a variable that is undated in the timer_0 ISR. When it reaches the target value I toggle the state of the heartbeat LED and reset the variable.

    The serial "stuff" is code that I include in almost all of my projects and probably fairly common RS-485 stuff with the exception that it supports our proprietary protocol. I don't think I've made a change to any of that code in over 5 years.

    My normal operating mode is to get the code for new boards to the communications, heartbeat and test port point and then begin to test the actual board. I'm reasonably confident that the board is functioning as expected since the code works in the emulator.

Children
  • If everything works in the emulator on your hardware, that's a good sign.

    If you can figure out exactly what's different between the emulator and your target hardware, that's where to look. Differences might include:

    • RAM: Works on emulator but maybe not on target.
    • RAM: More on emulator than on target.
    • Oscillator.
    • Bus speed/configuration.

    Hopefully, this list will help get you looking in the right place.

    Jon

  • So this heart:

    The heartbeat is in my main loop and it watches a variable that is undated in the timer_0 ISR.

    doesn't beat, but you stated earlier that the timer_0 ISR works. That suggests the code never makes it into main(). It could be stuck in the startup code.

    So go a couple steps down in complexity: no startup to speak of, just flip a single port pin in a super-tight loop. In other words, go back to BLINKY.

  • Yes, I decided to do just that after the 'U' out the serial port failed.

    It worked...I think now that it is a difference between the way the RAM is handled between the emulator and the 'actual' chip. However, I haven't ruled out anything as yet.