7 Blinking a 3V LED with VDD at 1.8V

Following the instructions in the Hardware Configuration section to supply VDDIO2 with 3.3V and VDD with 1.8V. Make sure that VDDIO2 and VDD have the correct voltage levels by using a multi-meter.

Following the instruction in the Reading the Status Bit section, we check that VDDIO2 is within acceptable range before starting the blinking.

Make sure the LED has a forward voltage of approximately 3V by using a multimeter with diode testing capabilities. A green LED usually has a forward voltage of approximately 3V.

An external green LED in series with a resistor of at least 15 Ohms needs to be connected to PC0, like shown in the figure below.

If a different LED is used, the resistor value needs to change. This is calculated using the following formula where VLED is the voltage drop of the LED and ALED is current through the LED:

R = V D D I O 2 V L E D A L E D

Warning: The AVR DB can not be programmed below 2V, so to ensure proper operation, set VDD to 3.3V by dragging and dropping the provided text file “VDD3V3.txt” onto the “CURIOSITY” drive on your PC. When programming is done, lower VDD to 1.8V by dragging and dropping “VDD1V8.txt” to the “CURIOSITY” drive. Both .txt files can be found in the GitHub repository linked in the introduction.
Figure 7-1. Curiosity Nano AVR128DB48 - LED Circuit Physical Layout
Figure 7-2. LED Circuit Schematics
/*Blinking a 3V LED with VDD at 1.8V*/

/*Set LED pin to output*/
void LED_PC0_init(void)
{
    PORTC.DIRSET = PIN0_bm;
}

/*Toggle LED pin*/
void LED_PC0_toggle(void)
{
    PORTC.OUTTGL=PIN0_bm;
} 

int main(void)
{
    LED_PC0_init();
    while (1) 
    {
        /*Check if VDDIO2 is within acceptable range*/
	 if(MVIO.STATUS & MVIO_VDDIO2S_bm)
	 {
	     /*Blink LED at PC0 forever*/
	     while (1)
	     {
		  LED_PC0_toggle();
		  _delay_ms(250);
	     }	
        }
    }
}

The code for this example is available in the blinking-a-3v0-led-with-vdd-at-1v8 folder in these github repositories