Printing Debug information

Go To Last Post
9 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hello all,

 

I am currently trying to debug an application that has delays using the _delay_ms() routine. These delays are necessary as it will give certain components time to setup properly. The code that I am debugging is past these delays.

 

If I have the optimization turned off, then the delays will not work and my application will fail and restart (surprise!).

 

So, I was thinking that I could print out debug information to the console. What I ma calling the console is actually the output screen in atmel studio. I am debugging on an AT90USB1287 using the ATMEL ICE. The interface that I am utilizing is JTAG.

 

I was wondering if I could print to the debug console over the JTAGE interface? Or if that is still a no go? I was reading that I could use the OCDR register but there were some issues (see this link: http://www.avrfreaks.net/forum/d...). Since it has been sometime since AVR studio 4, I was wondering if this method has been fixed and is now viable?

This topic has a solution.
Last Edited: Mon. Oct 2, 2017 - 07:52 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Most of us would use the USART for that!

 

Jim

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

philm0 wrote:
If I have the optimization turned off, then the delays will not work and my application will fail and restart (surprise!).

Well, you haven't told us which toolchain, but we can guess GCC.

 

1)  What does the doc tell you about optimization and the delay facilities?

Note

In order for these functions to work as intended, compiler optimizations must be enabled, and the delay time must be an expression that is a known constant at compile-time. If these requirements are not met, the resulting delay will be much longer (and basically unpredictable), and applications that otherwise do not use floating-point calculations will experience severe code bloat by the floating-point library routines linked into the application.

Now, why that would be related to "fail and restart" is a bigger question.  One guess would be that the watchdog timer is enabled, and with the delays taking a long multiple of expected that it is a watchdog reset?  Have you examined the reset cause?

 

2)  Why in the world would you want to disable optimization?  As you can see, you will cause many more problems than you might hope to solve.

 

3)  I, too, will use delay facilities after reset and port directions are set for the app.  It is convenient sometimes in these don't-care situations. Beyond that they rarely have any justified use in a "real" app IME.

 

3a)  And for such cases, a timer can be employed to wait in one spot for a while.

You can put lipstick on a pig, but it is still a pig.

I've never met a pig I didn't like, as long as you have some salt and pepper.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Now, on to your real questions ... if you are already connected via an ICE, then why not just set breakpoints where needed and examine stuff?

You can put lipstick on a pig, but it is still a pig.

I've never met a pig I didn't like, as long as you have some salt and pepper.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

... and Atmel Studio can do the formatting by Data Visualizer via DGI.

Data types are standard types including double.

Atmel-ICE has USART and SPI; Power Debugger adds the others (UART, TWI)

An alternative is to create a protocol decoder/encoder for sigrok via a logic analyzer/digital signal generator.

 

Data Visualizer

Data Stream

http://www.atmel.com/webdoc/GUID-F897CF19-8EAC-457A-BE11-86BDAC9B59CF/index.html?GUID-A6CB54F0-041D-4B12-A3E1-97602C36ED7B

Data Visualizer

Data Gateway Interface (DGI)

http://www.atmel.com/webdoc/GUID-F897CF19-8EAC-457A-BE11-86BDAC9B59CF/index.html?GUID-1106DC87-9E9B-4331-991E-0B712AF7A037

Data Visualizer

Serial Port

http://www.atmel.com/webdoc/GUID-F897CF19-8EAC-457A-BE11-86BDAC9B59CF/index.html?GUID-809F8335-EF2C-40A1-9422-1C44F20EEE54

Atmel-ICE

Connecting to Data Gateway Interface

http://www.atmel.com/webdoc/GUID-DDB0017E-84E3-4E77-AAE9-7AC4290E5E8B/index.html?GUID-8D4DA50A-2099-481B-82E5-7B4885B82F11

Power Debugger

Data Gateway Interface

http://www.atmel.com/webdoc/GUID-EAD481FD-28E6-4CD5-87FB-5165E7687C12/index.html?GUID-D768034C-7BF9-4FE0-8320-C89B72B35625

Power Debugger

CDC Interface

http://www.atmel.com/webdoc/GUID-EAD481FD-28E6-4CD5-87FB-5165E7687C12/index.html?GUID-09600EC6-FB0F-49BF-A51C-A633CAC281A9

https://sigrok.org/

 

Edit : corrected multiple URL

 

"Dare to be naïve." - Buckminster Fuller

Last Edited: Fri. Sep 29, 2017 - 10:53 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The USART is already being take by another component. It is a wifi module. Now, I should also note that I am actually working on this remotely. I am a freelancer to another company and debugging ona  remote computer. So, if I need anything hardware done, I will need to ask and explain to the person that I am in contact with.

 

Yes, I am using the GCC toolchain.

 

I have set break points but many variables are reporting back that the variable have been optimized away.

This reply has been marked as the solution. 
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

philm0 wrote:
I have set break points but many variables are reporting back that the variable have been optimized away.

 

For debugging, if you need to see an intermediate variable, define it as volatile, then it will not be optimized out. 

You can return it to being non-volatile once the debugging is completed.

 

 

Jim

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

ki0bk wrote:

philm0 wrote:
I have set break points but many variables are reporting back that the variable have been optimized away.

 

For debugging, if you need to see an intermediate variable, define it as volatile, then it will not be optimized out. 

You can return it to being non-volatile once the debugging is completed.

 

 

Jim

 

 

Holy cow, how did I not run into this solution! Yes, this is a big help for debugging!

 

Now if only I can get past the delay but I am thinking that I can disable all of the delays in a particular section that I am debugging.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

Unless you debug by stepping through all of the code the delays should not be a problem. Use breakpoints and free-run past the delays to the interesting parts. Then single-step until you're about to hit the next delay.

"He used to carry his guitar in a gunny sack, or sit beneath the tree by the railroad track. Oh the engineers would see him sitting in the shade, Strumming with the rhythm that the drivers made. People passing by, they would stop and say, "Oh, my, what that little country boy could play!" [Chuck Berry]

 

"Some questions have no answers."[C Baird] "There comes a point where the spoon-feeding has to stop and the independent thinking has to start." [C Lawson] "There are always ways to disagree, without being disagreeable."[E Weddington] "Words represent concepts. Use the wrong words, communicate the wrong concept." [J Morin] "Persistence only goes so far if you set yourself up for failure." [Kartman]