SNIU028D February 2016 – September 2020 UCD3138 , UCD3138064 , UCD3138064A , UCD3138128 , UCD3138A , UCD3138A64
The FILTERPRESET register is used to preset the values in several calculated registers within the filter. Digital filter calculation has higher priority over the Presetting logic.
If the Filter is updating the target register with its calculated value exactly when the Filter Preset is enabled, the target register in the Filter is not written by preset.
Therefore in order for the presetting to be successful every time, you have to first make sure no calculation (Number Crunching) is executing inside the filter.
The two ways to insure that the digital filter is not calculating are:
In case the EADC triggering signal is connected to more than one source or as extra level of precaution, you can both disconnect the triggering and disable the filter.
There are three bit fields in the Filter Preset Register. The PRESET_EN bit is set to enable the preset. The 3 PRESET_REG_SEL bits select which register will be preset, see the Section 4.12.25 for the exact values. Finally, the value to be preset is loaded into the PRESET_VALUE bits.
Here is an example code for using the preset register:
Filter0Regs.FILTERCTRL.bit.USE_CPU_SAMPLE = 0;
Filter0Regs.FILTERCTRL.bit.FORCE_START = 0;
LoopMuxRegs.SAMPTRIGCTRL.bit.FE0_TRIG_DPWM0_EN = 0; //Turn off DPWM trigger
asm(" nop"); //4 NOPs to let any Filter calculations to complete
asm(" nop");
asm(" nop");
asm(" nop");
Filter0Regs.FILTERCTRL.bit.FILTER_EN = 0; //Disable Filter
//PRESET YN to 0
Filter0Regs.FILTERPRESET.bit.PRESET_REG_SEL = 3; //Preset Filter0Regs.FILTERPRESET.bit.PRESET_VALUE = 0;
Filter0Regs.FILTERPRESET.bit.PRESET_EN = 1;
asm(" nop"); // Wait for the preset to take effect
// Preset of other filter registers (XN_M1, KI_YN, KD_YN,..) can be added here
Filter0Regs.FILTERCTRL.bit.USE_CPU_SAMPLE = 1; // Set use_cpu_sample
Filter0Regs.FILTERCTRL.bit.FILTER_EN = 1; // Enable Filter
Filter0Regs.FILTERCTRL.bit.FORCE_START = 1; // Force Start
Filter0Regs.FILTERCTRL.bit.FORCE_START = 0; // Clear Force Start
Filter0Regs.FILTERCTRL.bit.USE_CPU_SAMPLE = 0; //Release the use cpu sample
LoopMuxRegs.SAMPTRIGCTRL.bit.FE0_TRIG_DPWM0_EN = 1; //Turn on DPWM trigger