Close

Debugging

A project log for urban-edc-flashlight

Multifunction flash light for everyday carry

christoph-tackChristoph Tack 01/05/2022 at 21:020 Comments

Serial output

If you want to read the value of a variable inside your MCU, the easiest option is to just print it on the serial port.

TX-pin is PIN_PA1.

Calibrate your MCU-clock

  1. Set the fuse to enable clock output on PIN_PB2.
  2. Use a frequency counter (or an oscilloscope) to measure the frequency.
  3. When it's not correct you can adjust the frequency using the OSCCAL-register:
    void setup()
    {
        OSCCAL-=4;
    }
    

Disabling RX

void setup()
{
    OSCCAL-=5;//999.178kHz
    Serial.begin(4800);
    //Disable Serial RX
    ACSR &=~(1<<ACIE);
    ACSR |=~(1<<ACD);
}

void loop()
{
    Serial.print("Hello");
    delay(1000);
}

Discussions