| 36 | public: |
| 37 | |
| 38 | void run() { |
| 39 | |
| 40 | /* |
| 41 | * Set up Timer6 with an internal clock source and configured to be |
| 42 | * in master mode with update as the trigger |
| 43 | */ |
| 44 | |
| 45 | Timer6<Timer6InternalClockFeature,TimerUpdateMasterFeature> timer; |
| 46 | |
| 47 | /* |
| 48 | * Configure the timer with a reload value of 255 and no prescaler. |
| 49 | */ |
| 50 | |
| 51 | timer.initialiseTimeBase(255,0,TIM_CKD_DIV1,TIM_CounterMode_Up); |
| 52 | |
| 53 | /* |
| 54 | * Declare a DAC type with 12 bit right-aligned data. |
| 55 | */ |
| 56 | |
| 57 | typedef Dac1<DacChannel112BitRightAlignmentFeature> MyDac; |
| 58 | |
| 59 | /* |
| 60 | * Create the DAC parameters. The trigger for conversion will be timer 6's |
| 61 | * trigger output and the wave generation mode is triangular. |
| 62 | */ |
| 63 | |
| 64 | MyDac::Parameters params; |
| 65 | params.dac_trigger=DAC_Trigger_T6_TRGO; |
| 66 | params.dac_waveGeneration=DAC_WaveGeneration_Triangle; |
| 67 | params.dac_lfsrMaskOrTriangleAmplitude=DAC_TriangleAmplitude_1023; |
| 68 | |
| 69 | /* |
| 70 | * Declare the DAC object |
| 71 | */ |
| 72 | |
| 73 | MyDac dac(params); |
| 74 | |
| 75 | /* |
| 76 | * Set a base level of Vref/16. 4096 is the full 12 bit conversion value and that equals |
| 77 | * an output of Vref. Therefore 4096/16 = 256 for a base level of Vref/16. The triangle |
| 78 | * wave is added to this base value. |
| 79 | */ |
| 80 | |
| 81 | dac.write(256); |
| 82 | |
| 83 | /* |
| 84 | * Enable the trigger output and then Start the timer. Each time the update event is |
| 85 | * generated a DAC conversion is triggered. |
| 86 | */ |
| 87 | |
| 88 | timer.enableMasterFeature(); |
| 89 | timer.enablePeripheral(); |
| 90 | |
| 91 | /* |
| 92 | * Finished. It's all running in the background now. |
| 93 | */ |
| 94 | |
| 95 | for(;;); |
no test coverage detected