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.
Hi,
I'm using the motorcontrol SDK example univeral motorcontrol lab and there is nFault GPIO34 configured, to trip the ePWM modul and to shut down the controller.
I would like now to add another GPIO trip input, but I'm unable to make that working.
What I have done:
in hal.h - configured GPIO 25 as an additional trip pin:
//! \brief Defines the gpio for the nFAULT of Power Module #define MTR1_PM_nFAULT_GPIO 34 //! \brief Defines the gpio for the nFAULT of Power Module #define MTR1_PM_nFAULT_2_GPIO 25 ... //------------------------------------------------------------------------------ // XBAR-EPWM #define MTR1_XBAR_TRIP_ADDRL XBAR_O_TRIP7MUX0TO15CFG #define MTR1_XBAR_TRIP_ADDRH XBAR_O_TRIP7MUX16TO31CFG #define MTR1_IDC_XBAR_EPWM_MUX XBAR_EPWM_MUX05_CMPSS3_CTRIPL // CMPSS3-LP #define MTR1_IDC_XBAR_MUX XBAR_MUX05 // CMPSS3-LP #define MTR1_IU_XBAR_EPWM_MUX XBAR_EPWM_MUX00_CMPSS1_CTRIPH // CMPSS1-HP #define MTR1_IV_XBAR_EPWM_MUX XBAR_EPWM_MUX04_CMPSS3_CTRIPH_OR_L // CMPSS3-HP&LP #define MTR1_IW_XBAR_EPWM_MUX XBAR_EPWM_MUX01_CMPSS1_CTRIPL // CMPSS1-LP #define MTR1_IU_XBAR_MUX XBAR_MUX00 // CMPSS1-HP #define MTR1_IV_XBAR_MUX XBAR_MUX04 // CMPSS3-HP&LP #define MTR1_IW_XBAR_MUX XBAR_MUX01 // CMPSS1-LP #define MTR1_XBAR_INPUT1 XBAR_INPUT1 #define MTR1_XBAR_INPUT2 XBAR_INPUT2 #define MTR1_TZ_OSHT1 EPWM_TZ_SIGNAL_OSHT1 #define MTR1_TZ_OSHT2 EPWM_TZ_SIGNAL_OSHT2 #define MTR1_XBAR_TRIP XBAR_TRIP7 #define MTR1_DCTRIPIN EPWM_DC_COMBINATIONAL_TRIPIN7 #define MTR1_IU_XBAR_OUT_MUX XBAR_OUT_MUX00_CMPSS1_CTRIPOUTH // CMPSS1-HP #define MTR1_IV_XBAR_OUT_MUX XBAR_OUT_MUX04_CMPSS3_CTRIPOUTH_OR_L // CMPSS3-HP&LP #define MTR1_IW_XBAR_OUT_MUX XBAR_OUT_MUX01_CMPSS1_CTRIPOUTL // CMPSS1-LP
In hal.c - configure the GPIO25 pin as input (I use an external pull up):
GPIO_setPinConfig(GPIO_25_GPIO25); GPIO_setDirectionMode(25, GPIO_DIR_MODE_IN); GPIO_setPadConfig(25, GPIO_PIN_TYPE_STD);
In hal.c - set the trip zone:
XBAR_setEPWMMuxConfig(MTR1_XBAR_TRIP, MTR1_IU_XBAR_EPWM_MUX); // Configure TRIP7 to be CTRIP1H and CTRIP1L using the ePWM X-BAR XBAR_setEPWMMuxConfig(MTR1_XBAR_TRIP, MTR1_IV_XBAR_EPWM_MUX); // Configure TRIP7 to be CTRIP3H and CTRIP3L using the ePWM X-BAR XBAR_setEPWMMuxConfig(MTR1_XBAR_TRIP, MTR1_IW_XBAR_EPWM_MUX); // Disable all the mux first XBAR_disableEPWMMux(MTR1_XBAR_TRIP, 0xFFFF); // Enable Mux 0 OR Mux 4 to generate TRIP XBAR_enableEPWMMux(MTR1_XBAR_TRIP, MTR1_IU_XBAR_MUX | MTR1_IV_XBAR_MUX | MTR1_IW_XBAR_MUX); #endif // !(MOTOR1_ISBLDC || MOTOR1_DCLINKSS) // configure the input x bar for TZ2 to GPIO, where Over Current is connected --> //ToDo: Trigger another GPIO error XBAR_setInputPin(INPUTXBAR_BASE, MTR1_XBAR_INPUT1, MTR1_PM_nFAULT_GPIO); XBAR_lockInput(INPUTXBAR_BASE, MTR1_XBAR_INPUT1); XBAR_setInputPin(INPUTXBAR_BASE, MTR1_XBAR_INPUT2, MTR1_PM_nFAULT_2_GPIO); XBAR_lockInput(INPUTXBAR_BASE, MTR1_XBAR_INPUT2); // Configure Trip Mechanism for the Motor control software // -Cycle by cycle trip on CPU halt // -One shot fault trip zone // These trips need to be repeated for EPWM1 ,2 & 3 for(cnt=0; cnt<3; cnt++) { EPWM_enableTripZoneSignals(obj->pwmHandle[cnt], MTR1_TZ_OSHT1); EPWM_enableTripZoneSignals(obj->pwmHandle[cnt], MTR1_TZ_OSHT2); EPWM_enableTripZoneSignals(obj->pwmHandle[cnt], EPWM_TZ_SIGNAL_CBC6); //enable DC TRIP combinational input EPWM_enableDigitalCompareTripCombinationInput(obj->pwmHandle[cnt], MTR1_DCTRIPIN, EPWM_DC_TYPE_DCAH); EPWM_enableDigitalCompareTripCombinationInput(obj->pwmHandle[cnt], MTR1_DCTRIPIN, EPWM_DC_TYPE_DCBH); // Trigger event when DCAH is High EPWM_setTripZoneDigitalCompareEventCondition(obj->pwmHandle[cnt], EPWM_TZ_DC_OUTPUT_A1, EPWM_TZ_EVENT_DCXH_HIGH); // Trigger event when DCBH is High EPWM_setTripZoneDigitalCompareEventCondition(obj->pwmHandle[cnt], EPWM_TZ_DC_OUTPUT_B1, EPWM_TZ_EVENT_DCXL_HIGH); // Configure the DCA path to be un-filtered and asynchronous EPWM_setDigitalCompareEventSource(obj->pwmHandle[cnt], EPWM_DC_MODULE_A, EPWM_DC_EVENT_1, EPWM_DC_EVENT_SOURCE_FILT_SIGNAL); // Configure the DCB path to be un-filtered and asynchronous EPWM_setDigitalCompareEventSource(obj->pwmHandle[cnt], EPWM_DC_MODULE_B, EPWM_DC_EVENT_1, EPWM_DC_EVENT_SOURCE_FILT_SIGNAL); EPWM_setDigitalCompareEventSyncMode(obj->pwmHandle[cnt], EPWM_DC_MODULE_A, EPWM_DC_EVENT_1, EPWM_DC_EVENT_INPUT_NOT_SYNCED); EPWM_setDigitalCompareEventSyncMode(obj->pwmHandle[cnt], EPWM_DC_MODULE_B, EPWM_DC_EVENT_1, EPWM_DC_EVENT_INPUT_NOT_SYNCED); // Enable DCA as OST EPWM_enableTripZoneSignals(obj->pwmHandle[cnt], EPWM_TZ_SIGNAL_DCAEVT1); // Enable DCB as OST EPWM_enableTripZoneSignals(obj->pwmHandle[cnt], EPWM_TZ_SIGNAL_DCBEVT1); // What do we want the OST/CBC events to do? // TZA events can force EPWMxA // TZB events can force EPWMxB EPWM_setTripZoneAction(obj->pwmHandle[cnt], EPWM_TZ_ACTION_EVENT_TZA, EPWM_TZ_ACTION_LOW); //ToDo: Possible to trip to high, so that the motor is coasting EPWM_setTripZoneAction(obj->pwmHandle[cnt], EPWM_TZ_ACTION_EVENT_TZB, EPWM_TZ_ACTION_LOW); }
So, I cannot see, what I'm missing. It seems to be configured exactly like the GPIO34 pin and should trigger TZ2. Is there something missing with the comparator?
Edit: What I added to hal.c:
... XBAR_setInputPin(INPUTXBAR_BASE, MTR1_XBAR_INPUT2, MTR1_PM_nFAULT_2_GPIO); XBAR_lockInput(INPUTXBAR_BASE, MTR1_XBAR_INPUT2); for(cnt=0; cnt<3; cnt++) { ... EPWM_enableTripZoneSignals(obj->pwmHandle[cnt], MTR1_TZ_OSHT2); ... }
Edit 2: I also tried the example epwm_ex1_trip_zone from here: C:\ti\c2000\C2000Ware_4_00_00_00\driverlib\f28002x\examples\epwm
The thing is, when I for example use GPIO13 like the following, I can trip:
uint32_t gp = 13; GPIO_setPinConfig(GPIO_13_GPIO13); GPIO_setDirectionMode(gp, GPIO_DIR_MODE_IN); GPIO_setPadConfig(gp, GPIO_PIN_TYPE_PULLUP); GPIO_setQualificationMode(gp, GPIO_QUAL_ASYNC); XBAR_setInputPin(INPUTXBAR_BASE, XBAR_INPUT2, gp);
But when I use for example GPIO14, it does not work. Also when I just use the PULLUP config for the GPIO14, it never pulls it up.
So, do not all GPIO have a pullup and work as a input for the XBAR?
Sebastian, can you show only the lines of code you added to the hal.c? what was already there and what is new for your new TRIP?
I found out, that when I use GPIO35 for example, it works, but only when I pull it up with an external pull up. Somehow the internal pullup does not work in the universal motor control example, also when I initalize it correctly. In the ePWM example it works fine.
Internal pull ups are weak by design. They are not able to provide a lot of current.
Were you using the INTERNAL PULL UP TO TRIGGER the TRIP?
In the universal motorcontrol lab the pullup on GPIO35 does not work (the input stays low always), in the epwm example from above, it works. I really don't understand why the XBAR is so GPIO dependent (why for example GPIO14 will not trigger) and I really cannot find anything about that in the datasheet.
Hi Sebastian,
I am assuming you are using the LaunchPad for this device. On the LaunchPad, GPIO14 is connected to many other sources so the internal pull-up is too weak in this case. The XBARs are not GPIO dependent, you would not run into this issue on a custom PCB.
Refer to this file in your C2000Ware installation to see all of the GPIO connections on the LaunchPad:
/boards/LaunchPads/LAUNCHXL-F280025C/RevA/MCU089A(001)_Sch.PDF
With regards to GPIO25 not triggering TZ2, make sure the settings for GPIO25 are not being changed anywhere else as this is a very large project using many different resources. Otherwise the code you added looks correct.