From bc14a5653ca23b50e127d7ff4e3a731e349a7a8c Mon Sep 17 00:00:00 2001 From: Leon Krieg Date: Tue, 1 Oct 2024 00:16:20 +0200 Subject: [PATCH] Burn fuse for external crystal at 16K CK and 65ms --- Makefile | 4 ++-- src/bus/usart.c | 2 +- src/main.c | 15 ++++++++++++++- 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index c854174..a48e271 100644 --- a/Makefile +++ b/Makefile @@ -57,8 +57,8 @@ flash: $(TARGET) $(E) "[AVD] Flashing..." $(Q) $(AVD) -l $(LOGFILE) \ -c $(ASP) -p $(ARCH) \ - -U lfuse:w:0xff:m \ - -U hfuse:w:0x91:m \ + -U lfuse:w:0xFF:m \ + -U hfuse:w:0xD2:m \ -U flash:w:$< .PHONY: clean diff --git a/src/bus/usart.c b/src/bus/usart.c index 7f15677..156bf7d 100644 --- a/src/bus/usart.c +++ b/src/bus/usart.c @@ -27,7 +27,7 @@ int USART_Init(void) UCSR0B = BIT(RXCIE0); // Handle RXC interrupts UCSR0B |= BIT(RXEN0) | BIT(TXEN0); // Enable RX and TX circuitry - UCSR0C = BIT(USBS0) | BIT(UCSZ00) | BIT(UCSZ01); // 8-bit data, 2-bit stop + UCSR0C = BIT(UCSZ01) | BIT(UCSZ00); // 8-bit data, 1-bit stop, no parity UBRR0H = (USART_BAUD_PRESCALE >> 8); // Set baud rate upper byte UBRR0L = USART_BAUD_PRESCALE; // Set baud rate lower byte diff --git a/src/main.c b/src/main.c index a9a01d3..ed56b0b 100644 --- a/src/main.c +++ b/src/main.c @@ -57,6 +57,16 @@ static int Init(void) Info("Initializing..."); + // FIXME: Something is wrong here: + // - AVRDUDE sometimes fails to verify flash. + // - UART sometimes stops working. + // - External crystal problems? + // - Power supply problems? + // - Wrong fuses? Unlikely. + // - Bootloader problems? + + return 0; + // The watchdog timer is clocked from a separate // on-chip oscillator which runs at 1 MHz. Eight // different clock cycle periods can be selected @@ -232,10 +242,13 @@ int main(void) for (;;) { WDT_Reset(); - Update(); + Info("UPDATE"); + continue; + // Update(); WDT_Reset(); Sleep(1000); } + UNUSED(Update); return 0; }