AnsweredAssumed Answered

CTU Triggering for PWM VAL(0) in the wrong spot?

Question asked by duanemattern on Dec 14, 2016

I'm trying to implement Peter Vina's "MPC5643L PWM_ADC measurement concept " on the TRK-MPC5604P development board.  I've been having problems, so I'm doing it piece-meal, starting with the CTU triggering.  I finally got the triggering working by setting up an external trigger and monitoring it with the PWM signals using a logic analyzer.  The PWMs are modules 2 & 3 using A&B in independent mode.  They are center-aligned PWM signals (signed-mode), with Module 2B inverted and Module 3A inverted.  All that works fine.  I've been able to setup a trigger based on module2 Values (1-5) and I've setup the CTU such that I can generate an External Trigger on C14.   This works, but I'm having problem interpreting the results, but only for Values 0 and 1.


I expect the trigger on C14 to be center-aligned, when Module2 A is high, when the trigger is setup for a value of zero (0).  But that's not the case.  When the trigger values is set for value zero, I get the trigger when Module2 A is low, which is what I would interpret as Val(1), when the counter wraps-around.  The following is an example of what I'm taking about.


             FLEXPWM_0.SUB[2].TCTRL.R  = 0x0001;           /* Val(0) center  */

             FLEXPWM_0.SUB[2].INTEN.R = 0x04;                 //interrupt setup on Module2, Val(2); I toggle an output.


             CTU_0.TGSISR.B.I3_RE = 0x01;                           //Module 2 A is not inverted

             CTU_0.TGSCR.B.ETTM = 0x1;        //enable toggle mode for external trigger


I can get the desired result by using VAL(1) instead of VAL(0):

             FLEXPWM_0.SUB[2].TCTRL.R  = 0x0002;           /* Val(1) max  */


             CTU_0.TGSISR.B.I7_RE = 0x01;                           //Module 2 A is not inverted

But it seems to me that these results are swapped for the two values, VAL(1) and VAL(0). 


If I run this same test for Values of VAL(2), VAL(3), VAL(4), VAL(5), it behaves appropriately and I get what I expect, with the CTU external trigger corresponding to the specific PWM signal change.  I want to move on to the next step of triggering analog to digital conversion, but I want to make sure I fully understand this first, as I want to trigger the ADC at a specific time, and I'm going to use VAL(0) for that, but now I'll have to re-interpret when  that time is.