Sorry for the cross post. I originally posted my message in the “Development Platforms” section of this board. Probably this is is the correct location. If a moderator wants to delete one of the posts, please go ahead (there is no response in the other location).
Cross-posted at the Adafruit forums: https://forums.adafruit.com/viewtopic.php?f=63&t=167384
I’m sorry if this is a newbie question.
I’ve just purchased an Adafruit Grand Central M4, and Segger J-Link Mini Edu . Using VS Code with PlatformIO as my IDE, I compiled the classic Arduino “blink” program and downloaded it to the GC over the J-Link connection (using SWD). In the loop() function, this blink program turns on the built-in LED, inserts a delay (I tried various numbers, the classic example used 1000 ms), turns off the LED, inserts another delay.
If I run the program by itself (not in the debugger), everything works just fine. I ran this way by simply pressing the reset button on the GC. If I run the program within the debugger, I can step through and see the code executing, but the delay() seems to return immediately. The LED appears to be on continuously (but it is probably blinking very very fast).
I created a similar blink program, but using the millis() function to check the time in the loop() function, rather than using the delay() function. Again, this program runs fine outside of the debugger, but within the debugger millis() always returns 0. I set a breakpoint after the call and checked the return value.
Is there some known interaction between the debugging system and the timer on the GC? And is there a setting or workaround to allow debugging with delays and timers? If this question is answered elsewhere in the forums, a link or a search string to find that answer would be great.
The GCM4 includes a bootloader, which might be setting up some registers when it runs. Is it possible that these settings conflict with the debugger running under PlatformIO?
arduino-blink is the only example provided in the atmel-sam category which supports the Arduino framework. Apparently the GCM4 board only supports this framework. I am hoping that I can get this example running in PlatformIO as a starting point for future projects. So I was surprised when I ran into an issue which was not in the documentation.
Thanks in advance for your help.