ATMEL ICE debugging on atmega32

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

Hi,

 

I'm using AS7 and ATMEL ICE Debugger(JTAG Interface) for my atmega32 but always when starting debugging ("Start debugging and break") always Disassembler window comes up and it's not possible for me debugging in c-file(e.g. main.c).

try to set breakpoint in main.c but debugger always stays in disassembler window(PC rjmp 0x0000).

Is this a part of generating hex-file, elf-file when build project or anything else?

I've attached a picture of development board.

 

thanks for help.

 

jgan 

Attachment(s): 

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

It is "Debug" not "Release" that you are building/debugging?

 

The decision between showing you C or just plain Asm when debugging the code is dependent on whether the ELF file contains DWARF debug information. It does if the code is built for debug (-g option used) and doesn't if built for Release.

 

(unless Atmelchip have changed to always use -g? Haven't checked recently).

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

Zip up your AS7.0 project.  Attach the Zip file.

 

You will get an accurate answer.

 

Your dev board looks quite handy.   Especially the header pins.

I prefer one with an onboard USB Serial and debugger e.g. "Curiosity Nano"

Your dev board will work with a $10 Chinese JTAG-1 dongle (but only with AS4)

You already own an ATMEL-ICE.   Which works with AS7.0 (and every Atmel MCU)

 

David.

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


jgan wrote:
I've attached a picture of development board

rather than attach, it's more helpful to put it in the post - like this:

 

 

 

Then we can all see it in context!

 

smiley

 

See the Top Tips in my signature (below; may not work on mobile) for instructions ...

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

hi,

 

thanks for your helpful answers.

I've zipped these AS7 project and I've also made two pictures one from the atmega32 board with connected ICE and screen of disassembly window.

 

Juergen

Attachment(s): 

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

I don't have the hardware but just switched that to target the simulator and it happily does source level debugging after a rebuild.

 

Having said that, when I look at the "disassembly window.jpg" in the .zip file it looks like the cursor is positioned at _exit: / _stop_program which are part of the CRT and have no source (in other words the code has run to completion, exited main() and is back in the CRT.

 

This is possibly no surprise because in:

int main (void)
{
	// Ausgabe von einzelnen Zeichen -> 0123456789
	char c;

	uart_init();

	for (uint8_t i=0; i<=9; ++i) {
		c = i + '0';
		uart_putc( c );
		// verkuerzt: uart_putc( i + '0' );
	}
	
	//Ausgabe eines Strings -> textn
	//uart_puts("text");
	
	//x=uart_getc_wait();
	//uart_putc(x);
	//while (1) {
		//uart_putc( 1 );
	//}
	
	return 0; // never reached

}

I don't see any active while(1) that would hold it in main() - so it's free to hit the "return 0" and exit.

 

Try reinstating the commented while(1) and that hold it in your main.c

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

I've tried again with "while(1)" in main() but always the same, debugger stays in disassembler window at the same adress (rjmp pc-0x000).

is there anything to check when building the whole project?

setting in configuration window is "Debug" and Compilersetting for "Debugging" is set to -g3 and  "Optimization" is set to -Og but it seems that this is not the reason, maybe??

 

 

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

Thanks for the ZIP file.

 

You have some "unusual settings"

 

I suggest that you start again:

1.  Create a fresh project with a different name.

2.  Copy your old main.c to the new project's main.c

3.  Click on the "Tool" box next to MCU box on the last menu row.   (or Debug->Properties->Tool)

4.  Select ATMEL-ICE and JTAG.

5.  Debug->Start Debugging and Break.

 

You should see a yellow arrow at main()

You can step one line at a time with F10.

 

Report back.  (with luck everything works normally)

 

If ok,   I will try to explain where things went wrong.    (I have connected ATMEL-ICE to a real ATmega32 running at 8MHz and unzipped your project to AS7.0)

 

David.

Last Edited: Fri. Jan 24, 2020 - 06:00 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi David,

 

thanks but nevertheless again disassembler window comes upsad

I did it now with your instructions in last posting but yeah.... don't not really know what's wrong?

could it be that the µC at the evalboard might be corrupt or do I have to check configuration settings again?

starting with simulator it works but why is it not possible with ICE..

maybe it's only a few setting I missed?

 

Juergen

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

I've something forgotten.

when debugging I always have to use Button "Attach to target" otherwise error message comes up("devices signature does not match. make sure you have selected right device...")

 

after that disassembler window comes up.

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

Seriously.   Close AS7.0.   Start again.    I would expect everything to work properly with the AS7.0 default values.

 

No.   You should be able to connect automatically with JTAG.    e.g. in Tools->Device Programming.

 

Start Debugging and Break should work.       No need to "Attach to Target"

 

As I said.   I have the exact hardware.    Post a ZIP of your new project.

 

What is the full part number printed on the AVR chip?

 

David.

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

in the meantime I've changed µC to atmega16(breadboard setup, see att.) and tried something but today and now I'm able to debug.smiley

I can debug in main.c as I expected.

 

atmega32 might be a internally problem don't know exactly, but hopefully I've some other µC available at my desk....

 

two questions additionally:

- concerning debugging what is the best setting therefore? or in other words what is the main difference between Debug Level Minimum(-g1) and (-g3)?

- concerning optimization when do I need Optimization Level -Og instead of -O1 or O2, or -O3?

 

thanks a lot

 

 

Attachment(s): 

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

What is the full part number printed on the AVR chip?

 

I am gobsmacked by your ATmega16 breadboard photo.

Please invest in some 100nF capacitors.

 

I suggest that you remove the AVRISP-2.

Your ATMEL-ICE can program and debug via JTAG.

 

I think that AS7.0 will default to -O1

Just get familiar with -O1

 

-O0 is very unwise.   It breaks timing.   It generates appalling code.

-Og might feel more comfortable than -O1

-O2, -O3, -Os are fine for Release.   Not so good for Debug.

 

Regardless of Optimisation levels GCC is likely to put some variables into registers.

 

But first off,   I would get your dev board working.

 

David.

 

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

david.prentice wrote:
But first off,   I would get your dev board working.

I believe there are power and gnd pins on both sides of the chip and they all need to be connected to the power source,

and both need the 100nf caps David talks about!

Jim

 

 

 

(Possum Lodge oath) Quando omni flunkus, moritati.

"I thought growing old would take longer"

 

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

atmega16: part number is 16PU 1431 of the AVR on the breadboard.

I used this quick and dirty variant only to get an fast answer excluding ATMEL ICE because the tool have to be work I bought it few days ago.

 

atmega16 chip is powerd up with 5V, see red and black wires on pin 20(gnd) and pin 40(vcc).

the caps with 100nF yes i have to put it anyway, I will do this, thanks.

 

AVR ISP was disconnected as you've seen it at the picture.

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

I asked about the part number of the AVR on your dev board.

 

I would try to get the dev board working first.   At least it has capacitors.

And we can help you with AS7.0

 

You have an expensive ATMEL-ICE.

It is worth learning how to get the best results.

 

David.

Last Edited: Sat. Jan 25, 2020 - 08:21 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

AVR part number is atmega32A AU 1410.

I've attached the zip file (including all files) supplied by the distributor.

the product description is in german sorry for this.

I bought it in germany and this board is now not more available.

 

thank you David for your patience smiley

Attachment(s): 

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

Does not time fly?

 

The ATmega32 on my dev board is 0522 i.e. 2005

Your ATmega32A was made in Week 10, 2014

 

Your schematic does not have as many 100nF capacitors as I would expect.   But it should work.

 

In AS7.0

Tools->Device->Programming: Select ATMEL-ICE, ATmega32A, JTAG.  

Read Signature. 

Read Fuses.   Report hex values for Fuses

 

Your original AS7.0 project has some unusual settings.

I would expect the new project should work with the AS7 default settings.

 

Select Simulator as Debug Tool.

Debugging should work normally in Simulator.   i.e. filled red circle at Breakpoint.  yellow arrow at PC when Stopped

 

If everything is ok with Simulator,   select ATMEL-ICE JTAG as Debug Tool.

It should work exactly the same.

Report back.

 

David.

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

I've tried to connect to dev board as you wrote before but unhappily I'm not able, see att.

reset and power down/up dev board nothing happens it still the same windowsad

Attachment(s): 

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

I read Signature with my mega32.

Signature: 0x1E9502

Target Voltage: 5.0V

 

JTAG clock: 200kHz

 

JTAG id    0x4950203F

 

Fuses:   HIGH=0x97 LOW= 0xFF

 

There is clearly something wrong with your JTAG comms.

 

My dev board has 100nF capacitors that are about 8mm away from the VCC, AVCC pins on the DIP40 AVR.

The 8MHz XTAL is about 8mm from AVR pins.

 

My ATMEL-ICE cable goes into a 1.27mm 10pin -> 2.54mm 10pin adapter.   And then 100mm long Dupont wires.

 

So my "wiring" is not ideal.   Your dev board has a better JTAG "wiring".   Your VCC decoupling capacitor is "good enough".

Is your XTAL securely mounted in its socket?  (my XTAL is soldered to the pcb)

Is it loose in the socket?

 

As a last resort:  If you can get a good "Programming" connection,  I would change the fuses to "8MHz Int RC"

 

I am 99% confident that your AVR chip will be good.   Problems are normally simple e.g. loose socket,  dry solder joint, ...

 

David.

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

I've checked completely JTAG conn. to atmega32 and everything fine except on RESET pin

there's no connection between JTAG and atmega32 but this is ok because in schematics you can see that there's no conn. 

all other parts at the dev board like resistors caps are also fine and atmega32 is powered up...

 

Again as wrote before I'm not able to get communication via JTAG to atmega32 always last error message comes up.

I know that there was good connection formerly with other debug tool(olimex JTAG) but with this tool in last source code(uart) when starting debugging AS7 screen is frozen..

 

I tried also now with AVR MKII ISP Tool to get connection to atmega32 but negative.

 

so finally I'm a little bit helpless at the moment.

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

Ready made pcb with SMD components are a lot more reliable than through-hole pcb.

And much better than any breadboard.

 

JTAG can connect even if you have a bad XTAL.

The AVRISP-2 will not work if you have a bad XTAL.

 

I think that your dev board looks very useful.   It is worth checking pcb, soldering,  sockets, ...

 

This dev board looks like an alternative.

 

I would prefer a board with on-pcb Serial comms e.g. Arduino MEGA2560

Lots of pins.   You have to make your own JTAG adapter.    Enable JTAGEN with AVRISP-2.   Then connect JTAG (PF4-PF7 are A4-A7 pins on Arduino)

 

David.

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

thank you for the information to this alternative boards(atmega128 and Arduino MEGA2560).

In case of the Arduino version I think AS7 isn't possible for debugging isn't it?

 

 

Juergen