Background
I am programming a 40-pin ATMega4809 (datasheet) using ATMEL-ICE programmer. I'm simply using the Atmel Studio to upload a HEX file to the chip. I generate the HEX file using the Arduino IDE.
I'm using the very simple blink sample sketch with a slight modification which uses a different output pin for the LED.
const byte LED = 6;
void setup() {
// initialize digital pin LED as an output.
pinMode(LED, OUTPUT);
}
// the loop function runs over and over again forever
void loop() {
digitalWrite(LED, HIGH); // turn the LED on (HIGH is the voltage level)
delay(1000); // wait for a second
digitalWrite(LED, LOW); // turn the LED off by making the voltage LOW
delay(1000); // wait for a second
}
I have a LED (with resistor) connected to PA6 on the ATMega4809.
Code Result
I use the Export compiled binary choice in the Arduino IDE to generate the HEX file.
I then use Atmel Studio to upload the HEX file to the ATMega4809.
When I do, the program runs and the LED turns on.
However, I never see the LED turn off (blink).
Do you know why this might be true?
Things I've Tried
- I've tried increasing the delay value to see if internal crystal is set different and the timing is different or something.
- I've set the internal crystal to different values (ranging from 1Mhz to 20Mhz) and haven't seen any difference.
- I've considered that it could just be not looping, so I've tried various things to see if that were true or not.
- I've placed all of the code in the
setup()
function to see if it would working differently -- it didn't, it still just turned the LED on but never off. - I've tried turning LED on in
setup()
& off inloop()
to insure both are at least running once and they are.
NOTE: I know the HEX file is being properly uploaded because when I alter the program and upload different ones (turn on/turn off led) then the code does seem to either turn the LED on or off. I've also verified the code using Atmel Studio -- reading the chip's memory out to a file and doing diff.