Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
09/04/03 09:42
Read: times


 
#54051 - Newbie Debugging tools
Going by an E Mail that I got, it appears that the subject of debugging is one that haunts many a newcomer, when it comes to MCUs. This is particularly so when they use home-made-first-time-circuits and an assembler from the command line. WIth this setup they just get passed the assembly stage : 0 Errors. 0 Warnings : and then the drama starts - when the code is downloaded and powered up - nothing happens !

Time to debug and there are no tools. Not a very happy situation - particularly when the project due date is round the corner. At the very basic level a debug tool for a 8051 is any facility to read a maximum of 2 bytes at a time. One sample with a LCD module is given in this post.


I have tried listing some tips below. Maybe some of you can add to it.

Note: Specific sites and brands mentioned below have been tried by ME and found OK for ME and hence are only suggestions.

1. Before you try your hand in microcontrollers, take stock of the software tools at your command. You WILL need some method to probe the registers on the fly and read the values, to know where you are and where the bug is.

2. If budget is a constraint then visit www.pjrc.com and download the Paulmon monitor program and its help files. Nice one to start with and provides you with facilities to edit the code and data ram. And also some routines to send 16bit hex or ASCII values to screen.

3. If you can spend some money then just go in for a software development kit from Cygnal. That in my opinion is an excellent solution as it offers JTAG boundary scan. Debugging is then an issue of the past with its nice IDE. The whole assembler and size limited C-Compiler are from Keil- you cant ask for more.

4. Get hold of a software simulator - many are available for free - search links on left and thee shall find. If you go in for a commercial development kit, it mostly comes alongwith it. These are very handy to learn the 8051 instruction set; try out small code snippets; check maths algorithms.

5.If your hardware has some display device like a 7-Seg LED or character LCD module, then write a routine that can be called by your program to display 2 Byte values at a time. See the example below :

================================================
<pre>

;LCDSNAP is for sending the contents of two bytes pointed at by R1 to the LCD .
; Call with R1 pointing at the LSB of the 2 byte value to be displayed . And ACC must have starting point
; of the LCD cursor ( Uses A, B, R1)

LCDSNAP: MOV B, A ; Save the cursor loaction
MOV A, #01H ; Clr. Disp
CALL LCDCOM ; Routine to send accumulator content to Com.register of LCD
CALL DLY_5m ; 5 mS delay required for clear
HEX2LCD: MOV A, B
CALL LCDCOM
INC R1
CALL BYT2LCD ; Move High Byte to LCD
DEC R1
CALL BYT2LCD ; Move Low Byte to LCD
RET ; Replace RET with "JMP $" if you want to stop execution after call to LCDSNAP.

BYT2LCD: MOV A, @R1
SWAP A
CALL CNV2ASCI
CALL LCDCHR ; Display Hi nibble of Byte
MOV A, @R1
CALL CNV2ASCI
CALL LCDCHR ; Display Lo nibble of Byte
RET

; CNV2ASCI converts the lower nibble in accumulator to ASCII equivalent and returns Acc with converted value.

CNV2ASCI: ANL A, #00FH ; Strip the low bits alone
ADD A, #090H
DA A
ADDC A, #040H
DA A
RET
===========================================
How to use ?
Suppose you want to watch DPTR.

MOV SEEBYT, DPL ; SEEBYT is defined in IRAM
MOV SEEBYT+1, DPH
MOV R1, #SEEBYT
MOV A, #080H ; Starting point of LCD display
CALL LCDSNAP
JMP $ ; Display and wait for reset


Hints to use above : 1.Use your own routines for LCDCOM, LCDCHR and DLY_5m. You anyway will have these if you are using the LCD as display device.

2. This is just an idea - can also be used with 7seg LED displays as per your need.


Raghu

List of 16 messages in thread
TopicAuthorDate
Newbie Debugging tools            01/01/70 00:00      
   RE: Newbie Debugging tools            01/01/70 00:00      
      RE: Simulators            01/01/70 00:00      
         RE: Simulators            01/01/70 00:00      
            RE: Simulators -Andy / Erik            01/01/70 00:00      
               RE: Simulators -Andy / Erik            01/01/70 00:00      
                  RE: Simulators -Andy / Erik            01/01/70 00:00      
                     RE: Simulators -Andy / Erik            01/01/70 00:00      
   RE: Newbie Debugging tools            01/01/70 00:00      
      RE: Newbie Debugging tools            01/01/70 00:00      
      RE: Newbie Debugging tools- Michael            01/01/70 00:00      
         RE: Newbie Debugging tools- Michael            01/01/70 00:00      
            RE: Newbie Debugging tools- Michael            01/01/70 00:00      
               RE: Low Low Low Budget Debugging Tools            01/01/70 00:00      
                  RE: Low Low Low Budget Debugging Tools            01/01/70 00:00      
                  RE: Low Low Low Budget Debugging Tools            01/01/70 00:00      

Back to Subject List