platformio / platform-atmelmegaavr

Atmel megaAVR: development platform for PlatformIO
https://registry.platformio.org/platforms/platformio/atmelmegaavr
Apache License 2.0
28 stars 21 forks source link

delay() not working on Atmega808 #70

Closed fatgorille closed 2 months ago

fatgorille commented 2 months ago

I've encountered an issue with the delay() function on the ATMEGA808 microcontroller. When I run the following code, the uC freezes, and no signal is detected on the TEST_PIN:

`#include

define TEST_PIN 24

void setup() { pinMode(TEST_PIN, OUTPUT); // debug pin }

void loop() { digitalWrite(TEST_PIN, HIGH); delay(10); digitalWrite(TEST_PIN, LOW); delay(10); }`

However, when I replace 'delay(10)'; with 'delayMicroseconds(10000);', the code runs smoothly. Additionally, when I run this code on an ATMEGA4809, it works without any issues.

I noticed there's a similar issue reported here [https://github.com/MCUdude/MegaCoreX/issues/43], but I'm unsure if it applies to PlatformIO as well.

Could you please help me verify if this issue is specific to PlatformIO and provide guidance on how to address it?

fatgorille commented 2 months ago

After closer check, the toolchain was not up to date.

The toolchain installed were 1.70300.191015 (7.3.0)

By specifying the latested toolchain in platformio.ini 3.70300.220127 it fixes my issue.