If LGPTn.DESCEX[18] HBDF (Has deadband, Fault, and Park logic) bit is set to one, the LGPT implements the FAULT and PARK registers. The FAULT register is used to stop the timer upon an active fault input signal from the IOC. The PARK register can be used to set the IOC outputs of the LGPT to a given state when the timer has stopped as a result of fault.
The fault input overrides channel 0 IOC input when FAULT.CTL != DIS. See Figure 10-3.
This means that channel 0 receives fault as input signal when C0CFG.INPUT = IO and FAULT.CTL != DIS. CHFILT can be used to avoid glitching on the fault input. Fault is level triggered, the polarity is set by the C0CFG.EDGE field. Here C0CFG.EDGE = RISE gives active high and C0CFG.EDGE = FALL gives active low polarity.
Set the Fault mode by setting FAULT.CTL. There are four different modes:
- DIS: The counter ignores the fault input.
- IMMEDIATE: In this mode the counter stops immediately on an active fault input (2 system clock cycles of synch delay is expected). This is done by hardware by setting CTL.MODE = DIS. To start the counter software must set CTL.MODE != DIS. The RIS.FAULT interrupt is also set immediately on active fault input. If the RIS.FAULT input is cleared, it will not be set again while CTL.MODE == DIS even though the fault input is active. This is because the 2 stage synchronizers and the channel filter is not active while CTL.MODE == DIS. If the counter is started by setting CTL.MODE != DIS when the fault input is active it will immediately stop the counter and set RIS.FAULT.
- ZEROCOND: In this mode the counter stops when CNTR = 0 after an active fault input. If the RIS.FAULT flag has been cleared by software before CNTR= 0, and the fault input is inactive, the counter will continue as normal. When the counter stops on zero, it can be started again by clearing the RIS.FAULT flag. If you want to change the counter mode you should set CTL.MODE = DIS, clear the RIS.FAULT interrupt, then start timer in required mode. The channel filter will keep running while the CNTR is halted at zero. This ensures an up-to-date fault input.
- IRQ: In this mode only the RIS.FAULT interrupt is set on active fault.
General notes on Fault:
- When the channel filter is used together with Fault, and the timer is restarted, the fault input will not be evaluated before CHFILT.LOAD number of consecutive equal samples. This means that an active fault could have been present when the timer started (by setting CTL.MODE != DIS), but the timer will not stop before CHFILT.LOAD samples.
- In IMMEDIATE mode clear RIS.FAULT to start the timer again. Not doing so will immediately stop the timer upon start.
Example setup of Fault and Park.
- Set FAULT.CTL to wanted mode.
- Set C0CFG.EDGE = RISE/FALL. Here RISE = active high, and FALL = active low.
- Set C0CFG.INPUT = IO.
- (Optional) Config CHFILT
- (Optional) Config IMASK to set CPU interrupt on fault. Typically required.
- (Optional) Config PARK.
- Start timer in wanted mode.
Figure 10-10 and Figure 10-11 illustrate the consequences of some of the possible Fault and Park configurations.