Debugging Bascom programs in AVR Studio Print
Written by Jurij Mikeln   

Debugging is a procedure, where we trace program flow with the help of suitable software and/or hardware. While tracing program flow, we can find annoying “bugs” inside our program. If we do not have suitable debugging hardware we can use a simulator, like the one included in Bascom-AVR. We can also find problems by displaying some “debugging data” on an LCD display or in a terminal window, if we send data out to the RS232 or USB port. I will show you how you can debug Bascom programs with a help of the AVR Studio 4 program and the MegaPin development board.

As mentioned, we can debug in many ways. Generally we use a principle of displaying “debugging information” on an LCD display or terminal window. The data displayed can determine whether or not our program is performing properly.

That is a quite usable procedure if no debugging tools are on hand, however, this procedure is sometimes not good enough. In such cases, we have to look “inside” the microcontroller to find those nasty bugs that may be elusive. Atmel has provided many free software tools that, in conjunction with suitable hardware, work very well. A good example is Atmel’s JTAG ICE, which we’ll demonstrate in conjunction with the MegaPin development board (which has proven to be a real multi-

purpose development board!)

What do we need?

To debug using the AVR Studio 4 program, some device preparation (hardware & software) needs to be done. For hardware, you will need a JTAG ICE unit, the source of which can be found on the web. Alternately, you can use the JTAG ICE included on the MegaPin board. One must use an AVR device that supports JTAG, such as the ATmega16, ATmega32, to name a few. Also, we must enable JTAG operation with the appropriate Fuse bit, as shown in Figure 1. Note that all AVRs with JTAG available come factory-programmed with the JTAG Fuse bit enabled.

The JTAG Fuse bit can be turned on with the SPI programmer built-in to the MegaPin board, or we can use the STK500 programmer, in conjunction with Studio 4. We can also accomplish this from Bascom-AVR using the STK500 native programmer, as shown in Figure 2. Note that you do not need to turn on the OCDEN Fuse bit.

Once the JTAG Fuse bit has been programmed, we can continue by connecting the JTAG ICE interface to PortC via a 10-pin flat cable. The communication pins Rx and Tx of the ATmega16, should be connected to Tx and Rx of the FT232RL USB bridge device. All this is done on the MegaPin board by connecting PortC to socket CON16 with a 10-pin flat cable, and connecting jumpers J27 and J29 (VCC EN & JTAG EN) and, finally, disconnecting jumper J11. Now open AVR Studio 4 and press the Conn icon as shown in Figure 3.
You will see the window shown in Figure 4, where we can select the platform on the left, while on the right, we select the COM port (we suggest leaving it on Auto.)

Debugging Bascom programs in AVR Studio


Continue reading

Shop area

Last Updated on Wednesday, 01 August 2012 14:45