Yahoo Groups archive

AVR-Chat

Index last updated: 2026-04-28 22:41 UTC

Message

3 debugging questions

2004-12-20 by wbounce

I am using a 128 with WINAVR producing a dwarf2 and using avrstudio 4.1
for debugging.  
I use timer0 with a SIGNAL routine in most of the programs I have
written to provide a 1 ms timer. 

When I debug my code I have problems with delays. I have a function
called delay that does this

cli();
ms_count = 0;
sei();
while (ms_count< pnDelay)
	;

Even small values for pnDelay take a long time in the simulator.  Is
there some setting in AVR Studio that affects this? I remember somewhere
seeing a screen of options including speed for the MCU My timer setting
are based on 16MHZ but that was not one of the options. Am I the only
who experiences this? It is a pain having to wait 10 minutes until a 100
ms delay is done or having to step into certain functions so I can skip
the delay part. I do not want to change the values to a really low value
because I am afraid I would forget to set them back.


This leads me to my 2nd question. I have debug print statements to the
UART. Today I added a define efkdebug and put #ifndef efkdebug around
the code that actually sends the charactors to the uart so I would not
have to wait for them to timeout. Right now my define variable is
hardcoded. I would like to set up a new menu item in PN called Build
Debug and be able to have the Make file set the efkdebug define.  I know
there is a compiler command line option -D or -d that allows the
defining a variable. But how do I have PN pass the make file a parameter
that tells it to define debug. Working with make files is not my strong
suite. From what I read any variables are global. I only want to set it
if I am doing a build debug. 

If I get an answer for #2 I could create 2 sets of delay constants the
real one and a short set used for debugging.


Question number 3 is how do you deal with debugging code that handles
TWI (I2C) Right now I have to step into those functions and jugdicously
skip those steps. Is there a better way?

Attachments

Move to quarantaine

This moves the raw source file on disk only. The archive index is not changed automatically, so you still need to run a manual refresh afterward.