March 28, 2012

Methods for Debugging Microcontroller Hardware

Most of these debugging techniques can be applied to any microcontroller since they do not use any specific tools.

General debugging methods

There are many ways to debug hardware:




  • Ice.
  • Icd.
  • Simulation.
  • Serial Rs232.
  • Lcd.
  • Led.
  • Hardware pins.
  • Logic Analyzer.

Ice

The In Circuit Emulator is the most expensive way to debug your hardware. You buy a extra processor that physically takes the place of the normal processor. This extra processor allows software access to the internal carrying out of the processor (you can set breakpoints on hardware modules).

Icd (Pic microcontroller)

The next best thing to Ice is Icd (In Circuit Debug) Sometimes known as (Bdm - Background Debug Mode - for non Pic microcontrollers) let you singular step straight through code undoubtedly running in the target processor.

For Icd the processor has a small estimate of built in hardware that can halt the processor when the program reaches a specific address. The software can then read back all the registers and processor state.

Simulation

With a source code simulator you can step straight through the high level language code and see its follow on memory and variables without having to look at the collector code directly. This lets you focus on the high level language carrying out and lets you combine on the question you are trying to solve.

One great advantage of the simulator is that you do not have to wait to download and program the target processor (you do have to re-compile the code after changing its source code though). So you can cut out the time enchanting programming task just by using the simulator.

Note: Simulators are no good for debugging interrupts.

Debugging using hardware

Serial Rs232

Newer microcontrollers have a built in Uart giving you a virtually free debug tool that uses minimal resources and needs very small software coding.

For debug output you need to join together the Uart output pin (Tx) to a favorable level translator circuit e.g. A Max232 chip. You may even get away with direct connection (via a resistor) to the input of your Pc serial port (but this depends on the specifics of your Pc hardware) - using a translator chip will always work.

Advantages

  • Minimal coding.
  • Simple to use.
  • Minimal extra hardware.

Disadvantages

  • Takes a long time to output a character (~1ms).
  • Takes even longer for blocks of characters (~10s of ms).
  • Needs extra hardware.

Even straight through it takes time to output a character it is a beneficial debug tool as you can output the value of a variable to see what the microcontroller is undoubtedly doing.

Lcd

An Lcd (Liquid Crystal Display) gives a favorable way of displaying debugging information. It is also beneficial for many separate applications that need a text display output.

It is a module that displays text characters and a coarse screen size is 2 rows of 16 characters.

Most Lcd modules use the Hd44780 controller chip which is why Lcd routines built into high level languages always work.

Advantages

  • Very quick update (40us 4 bit data bus).
  • Useful in many projects as the main display interface.
  • Simple to interface to an 8 bit port (only needs six of the 8 bits).

Disadvantages

  • Uses up an 8 bit port.
  • Hardware is more expensive (e.g. Compared to a serial port chip).

Led

Using an Led as a microcontroller 'alive' indicator.

Even though it is such a simple thing to blink an Led on and off it is very beneficial as a debugging tool as you can tell at a look whether the code you just downloaded is working.

Sometimes you can will incorrectly set parameters on the programming software or compiler which will stop the code dead.

The Led indicator gives a quick health check for your microcontroller which is easy to see.

Pin Debugging

This is the simplest and crudest debugging method; using any ready port pin. Plainly set or reset this pin at any point in the code that you want to monitor.

It has minimal impact on the code speed or size and can give you the following information:

  • You can tell if the code is active.
  • It gives you the repetition rate.
  • It gives you the routine time length (if you set the pin at the start and reset it at the end).

Note: To do testing you need an oscilloscope or a frequency counter and time interval measuring tool.

Logic Analyzer

This tool attaches to the pins you want to survey and captures the waveforms displaying multiple traces on a singular display. It uses a trigger module that can be set to begin on combinations of the input signals or on their length. So you can trigger on specific patterns or on glitches or both.

For non-microcontroller based systems (e.g. 80486 based) where the data and address bus are exposed a logic analyzer can show the address and data organized into hex words i.e. Readable. Some can disassemble the instructions showing what the processor was doing at the trigger point.

For a microcontroller based principles the logic analyzer can be beneficial in examining peripheral carrying out e.g. For debugging the Spi or I2C busses some logic analyzers also have built in withhold for these protocols.

Another use for the logic analyzer is to capture output over a long period of time depending on the memory capacity of the logic analyzer.

Summary

In short there are many techniques to debug your hardware ranging from simple (an output pin) to involved (a logic analyzer). All of them can be beneficial depending on the question you want to solve.

You can find more data here and how to build a website like it here.

Methods for Debugging Microcontroller Hardware

Car AC Compressor Troubleshooting USB Cable Adapter iPhone S.S.C. Napoli News Blog