MCUdude / MegaCore

Arduino hardware package for ATmega64, ATmega128, ATmega165, ATmega169, ATmega325, ATmega329, ATmega640, ATmega645, ATmega649, ATmega1280, ATmega1281, ATmega2560, ATmega2561, ATmega3250, ATmega3290, ATmega6450, ATmega6490, AT90CAN32, AT90CAN64 and AT90CAN128
Other
384 stars 118 forks source link

ATmega128 Pin Configuration #176

Closed csmith608 closed 3 years ago

csmith608 commented 3 years ago

I am using this bootloader, optiboot_flash_atmega128_UART0_115200_7372800L_BIGBOOT.hex, for the ATmega128.

I was looking at the pin configuration for RXD0 pin and saw that PORTE0 is set to 0, meaning that the internal pull-up resistor is not activated. As I understand it, if the RX pin is left floating (as it is in my application) it could read garbage data and reset the controller. The fix is to activate the internal pull-up resistor. I was wondering why it wasn't activated in the bootloader and maybe how I could do it for my application.

Referencing page 66 and 87 https://ww1.microchip.com/downloads/en/DeviceDoc/doc2467.pdf

MCUdude commented 3 years ago

The bootloader is only actively running after getting a reset pulse. When the microcontroller is powered up, the bootloader starts, but immediately jumps to the user program without touching any registers.

When you're uploading a new program and bootloader is finished writing new content to the flash memory, it gets a new reset pulse from Avrdude. The USB to serial adapter is actively driving the RXD0 pin, and since it will start executing the user application within 1 second when no valid data is received, I see this as a non-issue.

csmith608 commented 3 years ago

I see, thank you for the explanation!