8.1 Set Up VDDIO2 Failure Detection
Todo:
- Edit mvio_init() so it enables the VDDIO2 status change interrupt
- Edit ISR(MVIO_MVIO_vect) to handle the VDDIO2 status change interrupt
- Plot the measured VDDIO2 values in MPLAB® Data Visualizer
Warning: This assignment assumes the hardware setup steps described in Assignment 6 have
been completed. If they have not been completed, the step-by-step instructions can
be found in MVIO Hardware Setup.
Info: The
DAC, ADC and OPAMP peripheral are all configured in the same way as it was done for
assignment 6. The description of the setup can be found in Measuring VDDIO2 Using the ADC.
- Enable the VDDIO2 status change
interrupt by editing mvio_init() to
include:
MVIO.INTCTRL = MVIO_VDDIO2IE_bm;
- Handle the interrupt by clearing
the interrupt flag and toggling LED0 by adding the following to
ISR(MVIO_MVIO_vect):
MVIO.INTFLAGS = MVIO_VDDIO2IF_bm; LED0_toggle();
- Understand how the VDDIO2
fault is injected when SW0 is pressed by lowering the op amp output by
looking at the ISR(PORTB_PORT_vect) found in
gpio.c.Info: When VDDIO2 goes below the acceptable range, the VDDIO2 Status bit goes low, triggering the VDDIO2 status change interrupt. When VDDIO2 is below the acceptable range, all the pins on PORTC are tri-stated. When VDDIO2 goes back up again, the values from the PORTC registers are loaded again.
- Verify that the solution/project builds by selecting the Build → Build Solution from the top menu bare in Atmel Studio or by pressing the F7 key.
- Flash the device by selecting the Debug → Start without debugging from the top menu bar in Atmel Studio or by pressing the Ctrl+Alt+F5 keys.
- Plot the measured ADC reading and
the status of LED0 in MPLAB® Data Visualizer by loading the workspace
Assignment7.json.Info: LED0 is active low, so the plot in MPLAB® Data Visualizer will show ‘
0
’ when the led is lighting and ‘1
’ when it is off.
Result: The
ADC measurements and SW0 states are plotted in MPLAB® Data Visualizer, as
shown in Figure 1.
It can be seen that as soon as SW0 is pressed and VDDIO2 goes below the
acceptable value, the VDDIO2 status change interrupt triggers, and the LED0 line
goes high. When SW0 is pressed again and VDDIO2 goes back into the
acceptable range, the LED0 goes back low. The blue line is the VDDIO2
reading, while the green line is LED0.