Claim Your: Useful

"Arduino Software Guide"

   Right Now...



General debugging methods

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

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 special processor that physically takes the place of the normal processor. This special processor allows software access to the internal operation 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 single step through code actually running in the target processor.

For ICD the processor has a small amount 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 through the high level language code and see its effect on memory and variables without having to look at the assembler code directly. This lets you focus on the high level language operation and lets you concentrate on the problem 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 consuming 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 little software coding.

For debug output you need to connect the UART output pin (TX) to a suitable 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 through it takes time to output a character it is a useful debug tool as you can output the value of a variable to see what the microcontroller is really doing.

LCD

An LCD (Liquid Crystal Display) gives a convenient way of displaying debugging information. It is also useful for many different applications that need a text display output.

It is a module that displays text characters and a common 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 extremely useful as a debugging tool as you can tell at a glance 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 available port pin. Simply 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 observe and captures the waveforms displaying multiple traces on a single display. It uses a trigger module that can be set to activate 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 system the logic analyzer can be useful in examining peripheral operation e.g. for debugging the SPI or I2C busses some logic analyzers also have built in support 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 complex (a logic analyzer). All of them can be useful depending on the problem you want to solve.





Learn to program in C

in easy steps.

Essential & EASY:

PIC C Programming Course:

CLICK HERE.




Privacy Policy | Contact | About Me

Site Map | Terms of Use | Links




Google

Recent Articles

  1. An Ultrasonic Distance meter project.

    Nov 25, 14 12:00 PM

    An PIC Ultrasonic Distance meter project using a PIC microcontroller which is ideal since it has a capture timer that can accurately measure the ultrasonic echo time, so calculating the distance is ea…

    Read more

  2. A dot matrix LED display project for an 8x8 or 5x7 led matrix.

    Nov 20, 14 04:58 AM

    How to drive a dot matrix LED display. This project shows you how to drive one with 64 LEDs (8 rows by 8 columns) or less e.g. 35 LEDs (7 rows by 5 columns).

    Read more

  3. USB Serial Port: How to setup an RS232 serial link through a USB port.

    Nov 20, 14 04:55 AM

    USB serial port: How to setup an RS232 serial link when you only have a USB port. There are two types of digital interfaces to consider...

    Read more

Custom Search

Sign up for MicroZine:
''The'' Microcontroller Newsletter


Enter your first Name and primary email address in the form below:

And receive absolutely FREE a full project for:


"Measuring Analogue Voltages
Without An ADC"

(Using only one pin).

Instant Download:
You Can
Get It Right Now

Warning: This project could be Removed
at any time.  

It will NOT be
available indefinitely SO

To avoid
disappointment get it:

Now



:
:
Don't worry -- your e-mail address is totally secure. I promise to use it only to send you MicroZine
Remember this is a project with full description and fully debugged C Source code - and it's not available from the main website.

You can only get it through this newsletter.


To get exclusive access Enter your first name Name and primary email address Now in the form above.:

But wait !

There's more...

You'll receive more
free and exclusive reports as well as site information and site product updates.

Scroll up to the form above and sign up NOW.  Don't forget it's FREE and if you don't like it you can unsubscribe at any time.

Click Here Now to use the form above to get your Valuable information absolutely free.



Social Bookmarking
Click & Add:
add to BlinkBlink
add to Del.icio.usDel.icio.us
add to DiggDigg
add to FurlFurl
add to GoogleGoogle
add to SimpySimpy
add to SpurlSpurl
Bookmark at TechnoratiTechnorati
add to YahooY! MyWeb
Readers comments

"I wanted to thank
you so so so much
for all the information
you have provided in
your site it's

SUPERB and FANTASTIC."


- Ranish Pottath


"This site really is
the best and my favorite.
I find here many useful
projects and tips."

- Milan

bursach<at>gmail.com

Learn PIC C Now
Wondering how to program your next project using C and need a great start?


"Awesome site,
very, very easy and nice
to navigate!"


- Matt
matt_tr<at>
wolf359.cjb.net


"I am a newbie to PIC
and I wanted to say
 how great your
site has been for me."


- Dave

de_scott<at>bellsouth.net

Learn Microcontrollers
"Interested in
Microcontrollers?"


Sign up for The
Free 7 day guide:

FREE GUIDE : CLICK HERE

"Your site is a great
and perfect work.
congratulations."


- Suresh

integratredinfosys<at>
yahoo.com

"I couldn't find the correct
words to define
yourweb site.

Very useful, uncovered,
honest and clear.

Thanks so much for
your time and works.
Regards."


- Anon