1

I do not have experience with micorcontrollers but I have something related to them. Here is and explanation of my issue:

I have an algorithm, and I want to calculate how many cycles my algorithm would cost on a specific avr microcontroller.

To do that I downloaded AVR-STudio 6, and I used the simulator. I succeeded in obtaining the number of cycles for my algorithm. What I wan to know is that how can I make sure that my algorithm is working as it should be. AVR-Studio allows me to debug using the simulator but I am not able to see the output of my algorithm.

To simplify my question, I would like some help in implementing the hello world example in AVR-Studio, that is I want to see "hello world" in the output window, if that is possible.

My question is not how to program the microcontroller, my question is that how could I see the output of a program in AVR-Studio.

Many thanks

neatnick
  • 1,489
  • 1
  • 18
  • 29
Maher Assi
  • 75
  • 3
  • 10
  • Atmel Studio still does not provide any means to display debug messages sent by the program simulated. Your only option is to place breakpoints at apropriate locations and then inspect the state of the device in the simulator. For example the locations in RAM where your result is stored, or the registers in which it may reside; maybe have a 'watch' set on a variable or expression. – JimmyB Jun 15 '13 at 21:21
  • Well thank you very much for your help, the problem is that my program is long and does much work, it is hard to track what it is doing. Also optimizations usually remove a lot of variables which I can watch. I think I should rely that it is working fine, because I tested it in visual studio and it had no problems. Thanks for help. – Maher Assi Jun 17 '13 at 05:36
  • Indeed, debugging sometimes becomes a real challenge due to compiler optimizations. For debugging (in the simulator) optimizations should thus be set to level 0 or 1. This should not have any effect on the result of your algorithm but it will require more memory and execution time. (N.b.: If your program yields different results on different optimization levels, which are not timing-related or memory problems, you probably have a bug in your code.) – JimmyB Jun 18 '13 at 21:28

2 Answers2

1

As Hanno Binder suggested in his comment:

Atmel Studio still does not provide any means to display debug messages sent by the program simulated. Your only option is to place breakpoints at apropriate locations and then inspect the state of the device in the simulator. For example the locations in RAM where your result is stored, or the registers in which it may reside; maybe have a 'watch' set on a variable or expression.

I think this is the best answer, watch vairables and memory while in debug mode.

Note: turn off optimization when you want to debug for infomation, or some variables will be optimized away.

Maher Assi
  • 75
  • 3
  • 10
  • Well, maybe AtmelStudio 6.2 offers something ... The problem is that char* is not displayed as text ... – hfrmobile May 07 '14 at 11:52
0

the best thing to test if algorithms work is to run them in a regular PC program and feed them with data and compare the results with ground trouth.

Clearly to be able to do this a good programming style is neccessary that separates hardware related tasks from the actual data processing. Additionally you have to keep architectural differences in mind (eg: int=16bit vs. int=32bit --> use inttypes.h)

vlad_tepesch
  • 6,681
  • 1
  • 38
  • 80
  • Agreed. To test the implementation of an algorithm this may be the most effective way. – JimmyB Jun 18 '13 at 21:30
  • You mentioned here the architectural differences, which would make one algorithm work on a platform and not on another. The solution I used was to check the data in the debugger, although that may be exhausting, it is the best practical solution – Maher Assi Jun 24 '13 at 08:14
  • @MaherAssi no, it is not. the best solution would be to run a test on sample data against some ground truth data. – vlad_tepesch Jun 26 '13 at 10:29
  • Also agree that a good software architecture separates hardware related tasks from actual data processing! – hfrmobile May 07 '14 at 11:47