MPC5746C Voltage Comparator Round Robin

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

MPC5746C Voltage Comparator Round Robin

478 Views
cholland
Contributor V

Hi,

I have some questions in regards to the round robin functionality of the Voltage comparator.

I am using CMP_2 to compare CMP2_16, CMP2_17 and CMP2_19 with Vin1.

Vin1 is set to a low DAC value.

If CMP2_16, CMP2_17 or CMP2_19 fall below that threshold, I would like to know which one it is.

If I am not mistaken, I think I might be able to accomplish this with the Round Robin approach. 

I am assuming the round robin cycles through the enabled inputs and if there is a match, sets the associated.

'Input changed flag'. Of course I will have to set the Falling Flag and Falling Flag Interrupt.

So, then in the interrupt routine, I would check the 'Changed flag' to see which input has changed.

Thanks,

void CMP_Register_2_config(void)
{
// Set Interrupt Priority
INTC.PSR[562].R = 0x8001; /* Vector # 562 Analogue_Comparator_Module_2 CMP2 */

CMP_2.C0.R = 0;
CMP_2.C0.B.DMAEN = 0; /* DMA Enable */
CMP_2.C0.B.IER = 0; /* Interrupt Enable Rising */
CMP_2.C0.B.IEF = 0; /* Interrupt Enable Falling */
CMP_2.C0.B.CFR = 0; /* Compare Flag Rising */
CMP_2.C0.B.CFF = 1; /* Compare Flag Falling */
CMP_2.C0.B.FPR = 0; /* Filter Sample Period */
CMP_2.C0.B.SE = 0; /* Sample Enable */
CMP_2.C0.B.WE = 0; /* Window Enable */
CMP_2.C0.B.PMODE = 1; /* Power Mode Select (High Speed) */
CMP_2.C0.B.INVT = 0; /* Comparator Invert */
CMP_2.C0.B.COS = 1; /* Comparator Output Select (Filtered or Unfiltered)*/
CMP_2.C0.B.OPE = 1; /* Comparator Output Pin Enable */
CMP_2.C0.B.EN = 1; /* Comparator Module Enable */
CMP_2.C0.B.FILTER_CNT = 0; /* Filter Sample Count */
CMP_2.C0.B.HYSTCTR = 0; /* Comparator hard block hysteresis control */

CMP_2.C1.R = 0;
CMP_2.C1.B.CHN7 = 0; /* Channel 7 (23) Input Enable */
CMP_2.C1.B.CHN6 = 0; /* Channel 6 (22) Input Enable */
CMP_2.C1.B.CHN5 = 0; /* Channel 5 (21) Input Enable */
CMP_2.C1.B.CHN4 = 0; /* Channel 4 (20) Input Enable */
CMP_2.C1.B.CHN3 = 1; /* Channel 3 (19) Input Enable */
CMP_2.C1.B.CHN2 = 0; /* Channel 2 (18) Input Enable */
CMP_2.C1.B.CHN1 = 1; /* Channel 1 (17) Input Enable */
CMP_2.C1.B.CHN0 = 1; /* Channel 0 (16) Input Enable */
CMP_2.C1.B.DPSEL = 0; /* DAC output to Plus side ANMUX selection */
CMP_2.C1.B.DMSEL = 1; /* DAC output to Minus side ANMUX selection */
CMP_2.C1.B.PSEL = 0x001; /* Plus Input MUX Control (Reference Input 0)*/
CMP_2.C1.B.MSEL = 0x000; /* Minus Input MUX Control(Reference Input 1) */
CMP_2.C1.B.DACEN = 1; /* DAC Enable */
CMP_2.C1.B.VRSEL = 0; /* Supply Voltage Reference Source Select (Vin1(0) or Vin2(1))*/
CMP_2.C1.B.VOSEL = 0x0; /* DAC Output Voltage Select */
/* (Vin/64) * (VOSEL + 1) */
/* (5/64) * (0 + 1) */
/* 0.078125 */

CMP_2.C2.R = 0;
CMP_2.C2.B.RRE = 1; /* Round-Robin Enable */
CMP_2.C2.B.RRIE = 0; /* Round-Robin interrupt enable */
CMP_2.C2.B.FXMP = 1; /* Fixed MUX Port (Plus Port(0) Minus Port(1) */
CMP_2.C2.B.FXDACI = 1; /* Fix DAC input to the fixed mux port side */
CMP_2.C2.B.FXMXCH = 0; /* Fixed channel selection */
CMP_2.C2.B.NSAM = 0; /* Number of sample clocks */
CMP_2.C2.B.ACOn = 0; /* The result of the input comparison for channel n. */
}

Labels (1)
0 Kudos
0 Replies