3.1 ADC Burst Mode With Event Trigger
Todo:
- Edit the adc_init() so that the ADC is in Burst mode and starts conversion on the event trigger
- Study the rtc_init() and event_system_init() so it is clear how they are configured
Info:
The Event System (EVSYS) enables direct peripheral-to-peripheral signaling. It allows a change in one peripheral (the event generator) to trigger actions in other peripherals (the event users) through event channels, without using the CPU. The RTC can be used to generate an event every time the timer overflows, and the ADC can be configured as a user that starts a conversion every time it receives an event.
- Change the adc_init() so
that:
ADC0.COMMAND = ADC_MODE_BURST_gc | ADC_START_EVENT_TRIGGER_gc;
- Study the rtc_init() and event_system_init()
in rtc.c and event_system.c, respectively. Make sure you
understand how they are configured. Info: The RTC is configured to run using the 32.768 kHz ULP internal oscillator and a prescaler of 1. The RTC period is calculated using the RTC clock frequency and the desired ADC result frequency ADC_RESULT_FREQ of 64 Hz.Info: The RTC overflow event is used as an event generator for event channel 0, and the ADC is listening to channel 0.
- Verify that the solution builds with no errors by selecting Build → Build Solution from the top menu bar in Microchip Studio or pressing the F7 key.
- Flash the device by selecting Debug → Start without debugging for the top menu bar in Microchip Studio or pressing the Ctrl+Alt+F5 keys.
- Plot the single ADC sample vs. the ADC average
result using the MPLAB Data Visualizer by loading workspace
Assignment2.json. Try changing the number of ADC samples by changing
the ADC_SAMPLES macro in adc.h. to see
what effect it has on the noise level of the signal.Tip: You can visualize the ADC result frequency by looking at how fast LED0 is blinking.Tip: To get a better view of the noise of the signals it is recommended to set the range and offset for both axis to 16 and 10 and apply no force on the sensor.
Result: Measuring the
analog signal from the Force click using the ADC in Burst mode and using the RTC and
event system to continuously trigger the ADC accumulation. The results should look
similar to Figure 3-1 when the
force sensor is pressed with varying force. When investigating the noise, it should
look similar to Figure 3-2, where
the force sensor is not pressed, and the range and offset is set to 16 and 10,
respectively.