Hello. I am Dmitry.
I had a very pleasant time studying your dw-link in practice, but in the end I ran into an unsolvable problem for me.
I try to debug following simply code on target board UNO (AtMega328P)
For debugging with dw-link I have built firmware according to default platformio.ini (from dw-link repository)
avr-g++ -Og -g -fno-lto main.cpp -o firmware.elf -mmcu=atmega328p -v
Than I start debugging the target with avr-gdb. And the avr-gdb hangs on line with _delay_ms(10);
Unfortunately the same behavior is achieved in VSCode Platformio IDE too.
I have tried debug with simavr. Fortunately the simavr is able to simulate _delay_ms(N)
simavr -m atmega328p -f16000000L -g1234
with simavr call _delay_ms(10) produce delay about two minutes... and program does not hang.
Also I test this code with MPLABX. I have my own PicKit4.
Debugger successfully completed _delay_ms(10) works fine too.
Could you help me to undestand why _delay_ms(10); produce such behaviour with your dw-link.
in background _delay_ms(10) uses assembler for delay.
Thank You!
Мy code is below.
`
define F_CPU 16000000UL
include <avr/io.h> //Defines pins, ports, etc
include <util/delay.h> //Functions to waste time
int main(void)
{
DDRB |= 0b00100000; //set direction
while (1)
{
for (long i =0; i<1000000;){//wait 1 sec
i++; } //This works fine....
PORTB = 0b00100000; //Turn on UNO board LED
_delay_ms(10); //_delay_ms(10); ( util/delay.h) this leads dw-link to an infinite loop
// debug system hangs
// also seems impossible to restart it programmatically only with Power OFF
Hello. I am Dmitry. I had a very pleasant time studying your dw-link in practice, but in the end I ran into an unsolvable problem for me.
I try to debug following simply code on target board UNO (AtMega328P) For debugging with dw-link I have built firmware according to default platformio.ini (from dw-link repository) avr-g++ -Og -g -fno-lto main.cpp -o firmware.elf -mmcu=atmega328p -v
Than I start debugging the target with avr-gdb. And the avr-gdb hangs on line with _delay_ms(10);
Unfortunately the same behavior is achieved in VSCode Platformio IDE too.
I have tried debug with simavr. Fortunately the simavr is able to simulate _delay_ms(N) simavr -m atmega328p -f16000000L -g1234 with simavr call _delay_ms(10) produce delay about two minutes... and program does not hang.
Also I test this code with MPLABX. I have my own PicKit4. Debugger successfully completed _delay_ms(10) works fine too.
Could you help me to undestand why _delay_ms(10); produce such behaviour with your dw-link. in background _delay_ms(10) uses assembler for delay.
Thank You!
Мy code is below.
`
define F_CPU 16000000UL
include <avr/io.h> //Defines pins, ports, etc
include <util/delay.h> //Functions to waste time
int main(void) { DDRB |= 0b00100000; //set direction while (1) { for (long i =0; i<1000000;){//wait 1 sec
i++; } //This works fine.... PORTB = 0b00100000; //Turn on UNO board LED
//------------------------------------------------------------------------------------------------------------------------
}
return 0; // This line is never reached } `