Page 247 - ARM Based Microcontroller Projects Using MBED
P. 247

8.32 PROJECT 27—ARBITRARY PERIODIC WAVEFORM            233
































            FIG. 8.107  The generated waveform.


            8.31.5 Program Listing

              The program listing (program: SineWave)isshown in Fig. 8.106. At the beginning
            of the program, variable aout is configured as analog output and is assigned to DAC
            port PA_4. The program consists of an endless loop. Inside this loop, a for loop is used
            which iterates 100 times with step size of 100 μs. Therefore, the period of the generated
            waveform is 100 100μs¼10ms. The amplitude of the waveform is shifted up so that it is
            always positive. The maximum and minimum values of the sin function are  1. There-
            fore, 0.5 1 takes values between 0 and 1, that is, the amplitude of the generated wave-
            form is between 0 and +3.3V. Fig. 8.107 shows the generated sine waveform. In this
            figure, the vertical axis is 1V/division and the horizontal axis is 5ms/division.




                    8.32 PROJECT 27—ARBITRARY PERIODIC WAVEFORM


            8.32.1 Description
              In this project, we generate an arbitrary periodic waveform with a period of 20ms where
            the details of the waveform are as shown in Fig. 8.108.
   242   243   244   245   246   247   248   249   250   251   252