SNIU028D February 2016 – September 2020 UCD3138 , UCD3138064 , UCD3138064A , UCD3138128 , UCD3138A , UCD3138A64
The DAC Ramp steps are controlled by two bit fields, the Switch Cycles per Step field and the DAC Step register.
The Switch Cycles per Step bits determine how many DPWM inputs are required before 1 step occurs. It has 7 bits, so the register can hold values from 0 to 127, corresponding to 1 to 128 cycles.
The Switch Cycle signal is a DPWM output. The DPWM output used for the Ramp module is the same as the one for dither above:
LoopMuxRegs.FECTRL2MUX.bit.DPWM3_B_TRIG_EN = 1;
//set DPWM3B up to trigger dither and ramp modules.
The step size is an unsigned value. The Ramp module logic checks the start and end values. If the start value is lower than the end value, the step size is added to the DAC value. If the start value is higher than the end value, the step size is subtracted from the DAC value.
The step size has a 10 bit fractional part, allowing very precise and also very slow ramps. There are 10 fractional bits, below the dither portion of the DAC. There are 8 bits matching the DAC value, including dither.
There is a register, not visible to the programmer, which retains the sum of the fractional bits between steps.
For instance, suppose that bit 8 was the only bit set in the DAC Step register:
FeCtrl0Regs.DACSTEP.bit.DAC_STEP = 0x100; //set bit 8 in DAC_STEP
Every step, 0x100 would be added to the step register. The sequence would look like this:
Hidden Step Register | DAC Register |
---|---|
0x000100 | 0x0000 |
0x000200 | 0x0000 |
0x000300 | 0x0000 |
0x000400 | 0x0001 |
0x000500 | 0x0001 |
0x000600 | 0x0001 |
0x000700 | 0x0001 |
0x000800 | 0x0002 |
0x000900 | 0x0002 |
0x000A00 | 0x0002 |