This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

F28M35H52C: C28 eCAP won't capture anything

Part Number: F28M35H52C
Other Parts Discussed in Thread: CONTROLSUITE, C2000WARE

Hello All,

Problem

I am trying to bring up an eCAP peripheral in the C28 core but can't make it capture any events and completely run out of ideas... Nothing is written in the CAP registers, the event flags stay 0. Please help me find the problem.

Setup 

Generic info

  • Pin: PE0_GPIO24
  • Peripheral: eCap1
  • SysClk: 150MHz
  • I am using an XDS100v2 JTAG for debugging
  • An incremental encoder is used to provide pulses to the pin through an RS-485 receiver

Code

ECap1Regs.ECCTL1.bit.CAP1POL = EC_RISING;
ECap1Regs.ECCTL1.bit.CAP2POL = EC_FALLING;
ECap1Regs.ECCTL1.bit.CAP3POL = EC_RISING;
ECap1Regs.ECCTL1.bit.CAP4POL = EC_FALLING;
ECap1Regs.ECCTL1.bit.CTRRST1 = EC_DELTA_MODE;
ECap1Regs.ECCTL1.bit.CTRRST2 = EC_DELTA_MODE;
ECap1Regs.ECCTL1.bit.CTRRST3 = EC_DELTA_MODE;
ECap1Regs.ECCTL1.bit.CTRRST4 = EC_DELTA_MODE;
ECap1Regs.ECCTL1.bit.CAPLDEN = EC_ENABLE;
ECap1Regs.ECCTL1.bit.PRESCALE = EC_DIV1;
ECap1Regs.ECCTL2.bit.CAP_APWM = EC_CAP_MODE;
ECap1Regs.ECCTL2.bit.CONT_ONESHT = EC_CONTINUOUS;
ECap1Regs.ECCTL2.bit.SYNCO_SEL = EC_SYNCO_DIS;
ECap1Regs.ECCTL2.bit.SYNCI_EN = EC_DISABLE;
ECap1Regs.ECCTL2.bit.TSCTRSTOP = EC_RUN;

This is btw the code directly from the reference manual (paragraph 8.7.4.1). I also read the whole eCAP section several times and verified this.

Things I checked

  • Clock is enabled to eCAP1, the TSCTR is counting up
  • GPIO MUX: this is according to the docs: GPAMUX2.GPIO24 = 1
  • The signal is really coming in, I can see it changing in GPADAT.GPIO24 with the debugger
  • The signal can be routed to a peripheral: I tried using the eQEP that is also available on this pin and within a few minutes I could make it count up/down.
  • My colleague is working with an f28069 and I asked him to fire up the debugger, enable clock for an eCAP and set the CAPLDEN and TSCTRSTOP bits. It worked. For. The. First. Try. I tried the same without any success.
  • I tried the same (and many many other) settings on eCAP2 and it also did not work.
  • I tried two different boards, with different silicon revisions: B and E.
  • I checked that no other pin is MUX-ed to the eCAP1.

One sidenote: when I mess with the event prescaler and set it to random numbers in succession sometimes an event is fired and a CAP register is loaded.

  • Hi Jason,

    The eCAP setup looks ok. Can you try one of the example from C2000ware/ControlSuite ?

  • Hello Santosh,

    Thanks for the tip. I checked the C2000ware example but there is no support there for the F28M35. The peripheral is the same as in the f28069 so I went with that, but did not help.

    Finally I installed the necessary parts of ControlSuite and checked the example. I did not need to even compile it to realize the solution:

    "The GPTRIPxSEL register must also be used to allow ECAP modules to capture data on a pin." (F28M35 reference manual, chapter 4.2.2)

    In my case: GpioTripRegs.GPTRIP7SEL.bit.GPTRIP7SEL = 24;

    And there is not a single mention of this (or the GPTRIP register) in the eCAP chapter. Not even in the code examples in the manual. If you have any way to push a note about it in the manual, please do it. I think it could be useful to other poor souls...