TMS320F28379D: EnDat Clock Issue: No PWM on GPIO6, Code Hangs in dataReady Check Loop

Part Number: TMS320F28379D
Other Parts Discussed in Thread: C2000WARE

Tool/software:

Hello,

I am working on a custom board based on the TMS320F28379D chip and attempting to implement SPI communication with an encoder using the EnDat library.

However, I am currently facing an issue. For SPI communication to work, a PWM clock signal must be generated from GPIO pin 6 and sent to the encoder. At the moment, this PWM signal is not being output. As a result, the spiRxFifoIsr interrupt is not triggered, and the condition endat22Data.dataReady = 1; is never satisfied. Consequently, the program remains stuck in the while (endat22Data.dataReady != 1) {} loop.

Please help me enable the PWM clock output on GPIO6.

  • Hello,

    There are software examples in C2000Ware that should help you with your code and PWM configuration : C:\ti\c2000\C2000Ware_5_04_00_00\driverlib\f2837xd\examples\cpu1\epwm

    Please let me know if you have any questions.

    Best regards,

  • Hello,

    First of all, I would like to clarify that I am not unfamiliar with how to configure and run PWM on the TMS320F28379D. My current objective is to drive an encoder using the EnDat library, and I am initializing it with the EnDat_Init(); function.

    During this initialization, the following functions are called:

    PM_endat22_generateCRCTable(NBITS_POLY1, POLY1, endat22CRCtable);
    PM_endat22_setupPeriph();
    PM_endat22_setFreq(ENDAT_INIT_FREQ_DIVIDER);
    retval1 = PM_endat22_setupCommand(ENCODER_RECEIVE_RESET, 0xAA, 0x2222, 0);
    PM_endat22_startOperation();

    However, these functions are defined in the precompiled PM_endat22_lib.lib file, so I am unable to inspect or debug the internal implementation directly.

    I suspect that one of these functions—most likely PM_endat22_startOperation()—should be configuring and outputting a PWM clock signal on GPIO6. Unfortunately, no PWM signal is currently being generated on GPIO6. As a result, the SPI receive interrupt is never triggered, and the condition endat22Data.dataReady == 1 is never satisfied. This causes the program to remain stuck in the corresponding loop.

  • endat_init.zip

    Please look at the code

  • Hello,

    Thank you for further clarification. Let me loop in relevant experts on EnDat library to better assist you with your inquiry.

  • Hello again,

    I’ve now resolved the previous issue — it appears the root cause was related to the .cmd file configuration.

    I would like to ask a follow-up question.

    I’m planning to use GPIO0, GPIO2, and GPIO4 as PWM outputs controlled by CPU2.

    However, in the EnDat_Init() function, I see that the clocks for ePWM1, ePWM2, ePWM3, and ePWM4 are all being enabled:

    CpuSysRegs.PCLKCR2.bit.EPWM1 = 1;

    CpuSysRegs.PCLKCR2.bit.EPWM2 = 1;

    CpuSysRegs.PCLKCR2.bit.EPWM3 = 1;

    CpuSysRegs.PCLKCR2.bit.EPWM4 = 1;

    This suggests that the EnDat library utilizes ePWM1 through ePWM4.

    Given that, I’m concerned there might be a conflict if I also try to use any of those PWM modules (specifically ePWM1–ePWM3) from CPU2.

    My question is:

    When using EnDat, are all four ePWM modules (1–4) reserved exclusively for its use?

  • On this device the CLBx clock is driven by the ePWMx clock. As I recall 3 out of 4 of the CLB tiles are used. The author must have just initialized all 4 clocks. 

    Regards

    Lori