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.