Hi
I have connected the output pulse of a Hall sensor to Gpio24 of my 28335 chip.
I know the pulse comes in because during the debug session, I check the pulse with GpioDataRegs.GPADAT.bit.GPIO24 in the watch window and see this bit toggle when I rotate the motor shaft. I also see the pulse coming on the scope and the values match.
Next, I initialize the ECap1 module with this code;
// ECap1 Register setting
ECap1Regs.TSCTR = 0; // Set Time Stamp Counter to 0
ECap1Regs.CTRPHS = 0; // Set Time Stamp Counter Phase Register to 0
ECap1Regs.CAP1 = 0; // Set Capture Register 1 to 0
ECap1Regs.CAP2 = 0; // Set Capture Register 2 to 0
ECap1Regs.ECCTL1.bit.FREE_SOFT = 2; // Counter does not stop on emulation suspend
ECap1Regs.ECCTL1.bit.PRESCALE = 0; // Prescale is set to divide by 1
ECap1Regs.ECCTL1.bit.CTRRST2 = 1; // Do not reset counter on Capture Event 2
ECap1Regs.ECCTL1.bit.CAP2POL = 1; // CAP2 Register will capture on falling edge
ECap1Regs.ECCTL1.bit.CTRRST1 = 1; // Reset Counter after a Capture Event 1
ECap1Regs.ECCTL1.bit.CAP1POL = 0; // CAP1 Register will capture on rising edge
ECap1Regs.ECCTL1.bit.CAPLDEN = 0; // Enable CAP1-CAP4 register loads
ECap1Regs.ECCTL2.bit.TSCTRSTOP = 0; // Make sure the counter is stopped
ECap1Regs.ECCTL2.bit.CAP_APWM = 0; // Enable ECap mode
ECap1Regs.ECCTL2.bit.STOP_WRAP = 0; // Wrap after Capture Event 1 in one-shot mode
ECap1Regs.ECCTL2.bit.CONT_ONESHT = 0; // Operate in Continuous mode
ECap1Regs.ECCTL2.bit.SYNCO_SEL = 2; // Sync Out signal is disabled
ECap1Regs.ECCTL2.bit.SYNCI_EN = 0; // Sync In is disabled
Then I prepare ECap1 for interrupt using this code;
ECap1Regs.ECEINT.all = 0x0000; // Disable all interrupts on ECap1
ECap1Regs.ECCLR.all = 0xFFFF; // Clear all interrupt flags for ECap1
ECap1Regs.ECEINT.bit.CEVT1 = 1; // Enable interrupt on Rising Edge signal
ECap1Regs.ECEINT.bit.CEVT2 = 1; // Enable interrupt on Falling Edge Signal
PieCtrlRegs.PIEIER4.bit.INTx1 = 1; // Enable Corresponding bit in PIEIER for CAP1
ECap1Regs.ECCTL2.bit.TSCTRSTOP = 1; // Start Timer Counter
ECap1Regs.ECCTL1.bit.FREE_SOFT = 2; // Counter is not affected by Emulation mode
PieCtrlRegs.PIEACK.bit.ACK4 = 1; // Enable Group4.x Interrupts to PIECTRL
In Main() I wait for the ECap interrupt by setting it up like this:
IER = M_INT4;
If I place this line in the code
ECap1Regs.ECFRC.bit.CEVT1 = 1; // force the interrupt
the interrupt will fire and I will branck to ISR, however, if I simply turn the motor to create the hardware interrupt, I don't branch to the corresponding ISR routine.
Any ideas?