If I have a project with more than one translation unit, AVR Studio only allows me to set breakpoints in the main c file.

It doesn't matter if I include the other files directly by #include "something.c" or by using their header.

A quick search on various embedded forums didn't result in any answer or even discussion regarding this topic. Is everyone using a single translation unit when debugging, or did I miss a feature in plain sight?

The project was generated by CodeVision, if it is of any relevance.

  • \$\begingroup\$ Check this atmel.com/webdoc/atmelstudio/ch05s07s02s01.html. \$\endgroup\$
    – Laki
    May 14, 2015 at 11:25
  • \$\begingroup\$ I seem to remember having a few similar hassles with AVR Studio but debugging seems a lot better under Atmel Studio. Any reason not to use that or were you just referring to it by the old name? \$\endgroup\$
    – PeterJ
    May 14, 2015 at 11:27
  • \$\begingroup\$ @PeterJ : I still need AVR Studio because Atmel Studio doesn't seem to work properly with some of my drivers (and it also lacks a feature which I need to use often in AVR Studio) \$\endgroup\$
    – vsz
    May 14, 2015 at 11:32
  • \$\begingroup\$ @Lazar : This is how I set the breakpoints in the main file. However, it doesn't work in other files. \$\endgroup\$
    – vsz
    May 14, 2015 at 11:34
  • 1
    \$\begingroup\$ @vsz what debugger are you using ? does it have software or hardware breakpoints ? If you have both, can you switch between hardware and software ? \$\endgroup\$
    – efox29
    May 21, 2015 at 21:04

2 Answers 2


Yes, you can.

It doesn't matter if the is in the main C file or not, if there is one path in the function call tree (which obviously has main at its root) where control passes the line, you should be able to set a breakpoint on it.

I use a JTAG debugger and in the debugger software I load an ELF file that links functions and variables in code to addresses in the HEX file. So if you are not able to debug through code, verify if you have something similar, and if yes, verify that it is generated properly.

Or you may have a different problem altogether. Some of your files may not be included in the compilation. Check your build log to verify this.


You need to include the other files in your project. As source files. Including them as #include, or their headers, doesn't work.

If you are including them with #include, you have a single translation unit. You need to set them up as multiple translation units to get break points to work.

All recent versions of GCC include smart-linker workarounds ( --combine-fwhole-program ) that are intended to be an alternative method of creating a single translation unit (single-translation unit programs are generally smaller and faster). You need to create your own make file to do that. I haven't tried using the debugger: it might work (because the IDE includes all the source files in the "source file" branch, or it might not work (because the IDE can't follow how the source files were linked).

  • \$\begingroup\$ I would, gladly, if only AVR Studio allowed me to add files manually to the COF. \$\endgroup\$
    – vsz
    May 26, 2015 at 11:35
  • \$\begingroup\$ COF ?? COFF ??. If you want the IDE to follow the source code to a break point, you need to load the source code in a way that the IDE understands. Right Click on Source Files. \$\endgroup\$
    – david
    May 27, 2015 at 1:22
  • \$\begingroup\$ I use the COF file generated by the compiler to load the project. If I right click on "Source Files" in AVR Studio, it doesn't allow me to add any files. \$\endgroup\$
    – vsz
    May 27, 2015 at 3:14
  • \$\begingroup\$ So, don't do that. Create a new project, load the source files. Build obj, map, and elf files. But Perhaps if you build an ELF file instead of COFF, it will include sufficient information to allow the IDE to identify other source files. \$\endgroup\$
    – david
    May 28, 2015 at 5:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.