The objective of this experiment is to get familiar with the triggering of a DAC by the Interrupt generated by a Timer, and the triggering of an ADC by a Timer through the internal interconnection among the microcontroller peripherals. The microcontroller has thus to be configured with two Timers, one of them generating Interrupt, one DAC and one ADC. The codes used in Experiments 4 and 5 will be combined after making minor modifications to perform the tasks specified below. Part A: Generation of Triangular Waveform by DAC triggered by a Timer A triangular waveform can be generated by a DAC by applying to the input of the DAC a repetitive sequence of numbers that increase linearly from zero up to a prescribed maximum value and then decreasing linearly back to zero. As the microcontroller has a built-in reference voltage VREF+ = 3.3V, the analog output voltage VA is given in terms of the digital 12-bit input ND by the relationship VA = 3.3ND / 4096. So if ND is incremented in 16 steps of 256 (=100H) each from an initial value 000H, and then decremented in 16 steps of the same step size, VA will go up linearly from 0V to 3.3V in 16 steps, and then go down linearly to 0V in 16 steps again. This cycle can be repeated endlessly to generate a triangular wave having a peak value 3.3V. The time period of the triangular wave will then be 32 times the time taken for each step in the DAC output. 1. Set up the Timer TIM3 in the basic Time Base mode with an 8MHz Clock and a Pre- scaler setting of 400 to generate Interrupts at time intervals TI = 100NA s, where NA is the ARR setting. 2. Define an integer variable cnt to count the number of Interrupts received and a Mode bit mode to decide whether the DAC input will be incremented or decremented after an Interrupt. Initialise cnt, mode and the DAC input all to zero. 3. Write an ISR to increment cnt and increment / decrement the DAC input by 100H depending on whether mode = 0 or 1. Reset cnt ( 0) and toggle the mode bit when cnt reaches the value 16. [Ref. Sections 16.1 16.5 of the Reference Manual RM0316 for the STM32F303 MCU, and sections 19.3.1 19.3.5 of the Reference Manual RM0351 for the STM32L476 MCU.] 4. Display, using Studio, the DAC output as a Curve on your laptop screen for different settings of ARR, starting with NA = 1 and going up in multiples of 10. Note how the shape of the displayed waveform is affected by the time interval between consecutive Interrupts, as decided by the ARR setting. Hence obtain an estimate of the time taken by Studio to display each point on the screen. Part B: Sampling the Triangular Waveform by ADC triggered by a Timer 1. Set the DAC output for a time period of 80ms (NA = 25), and connect it to an ADC input. Use TIM1 to trigger the ADC output @ 100Hz by suitably choosing the Timer parameters, using the internal connection between TIM1 channel outputs and ADC trigger inputs, as given in the interconnections among peripherals. [Ref. Sections 15.3.13 and 15.3.18 of the Reference Manual RM0316 for the STM32F303 MCU, and sections 18.4.13 and 18.4.18 of the Reference Manual RM0351 for the STM32L476 MCU.] 2. Tabulate the values of the ADC output in Hex format for two complete cycles of the triangular waveform, along with the values given by the triangular DAC output waveform. Compare the corresponding values and comment.