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.

CCS/TMS320F28379D: CLB : Combinatorial Logic exemple

Part Number: TMS320F28379D

Tool/software: Code Composer Studio

Hello,

I'm currently trying the CLB module. In the combinatorial logic exemple, and from what I understood, there are 2 modes (mode 1 = active low ; mode 2 = active high) corresponding respectively to those 2 equations in LUT_0 (almost same thing for LUT_1) :

(i0 & !i1 & !(i3 & !(i2 & i3)))       ;       (!i0 & i1 & i2 & !(i2 & i3))

First of all, i'm not sure how the inputs 0 and 1 works (corresponding both to the same "CTRDIR", weird ?). I think it allows to chose the mode ( i0 &!i1 = mode 1 ; !i0 & i1 = mode 2) but i'm not sure.

Then, my goal is to add a logic in LUT_2, which is, I think, not used, except in FSM_2  and in COUNTER_2 (LUT_2.OUT is displayed) but here again i'm not sure if it influence the final output.
This new logic i'm trying to make needs to compare, for exemple, ePWM1A and ePWM1B to create a third signal (ePWM3A) which will be HIGH only when 1A and 1B are HIGH (= check cross-conductions).

On my scope, I can visualize the third signal ePWM3 but I can't have any influence on it (by using the .syscfg) so I guess i'm doing something wrong. I have set my boundary.in4 like this in the .c file :

CLB_configGlobalInputMux(CLB1_BASE, CLB_IN4, CLB_GLOBAL_IN_MUX_EPWM3A);     so maybe my error comes from the .syscfg (I've set OUTLUT_1 to have eqn = i0 = LUT_2.OUT and I think this is right)

I know this is a lot of questions but i'm a beginner, so thanks you in advance for your time and your answers/advices.

  • 1. For the mode selection, think about the signals as:

    i0 &!i1 = ACTIVE when 0b10 = mode 1

    !i0 & i1 = ACTIVE when 0b01 = mode 2

    2. For you ePWM3A signal, the line of code below is selecting input to CLB1's TILE to be EPWM3A on BOUNDARY IN4. My understanding is that you are generating the PWM signal and you are trying to output it on EPWM3A.

    CLB_configGlobalInputMux(CLB1_BASE, CLB_IN4, CLB_GLOBAL_IN_MUX_EPWM3A);

    You can only overwrite the EPWM3 ouptput on CLB3's TILE. And then you have to output it on the GPIO by writing to the peripheral output intersect.

  • Thanks for your answer. 
    So I need to initalize ePWM3 like this ? Here's the code :

    #include "driverlib.h" #include "device.h" #include "clb_config.h" #include "clb.h" #define EPWM1_TIMER_TBPRD 2000U #define EPWM1_CMPA 1333U #define EPWM1_CMPB 667U #define EPWM2_TIMER_TBPRD 2000U #define EPWM2_CMPA 1333U #define EPWM2_CMPB 667U #define EPWM3_TIMER_TBPRD 2000U #define EPWM3_CMPA 1333U #define EPWM3_CMPB 667U void initEPWM1(void); void initEPWM2(void); void initEPWM3(void); void initCLB1(void); __interrupt void epwm1ISR(void); uint32_t mode = 0; void main(void) { Device_init(); Device_initGPIO(); Interrupt_initModule(); Interrupt_initVectorTable(); Interrupt_register(INT_EPWM1, &epwm1ISR); GPIO_setPadConfig(0, GPIO_PIN_TYPE_STD); GPIO_setPinConfig(GPIO_0_EPWM1A); GPIO_setPadConfig(1, GPIO_PIN_TYPE_STD); GPIO_setPinConfig(GPIO_1_EPWM1B); GPIO_setPadConfig(2, GPIO_PIN_TYPE_STD); GPIO_setPinConfig(GPIO_2_EPWM2A); GPIO_setPadConfig(3, GPIO_PIN_TYPE_STD); GPIO_setPinConfig(GPIO_3_EPWM2B); GPIO_setPadConfig(4, GPIO_PIN_TYPE_STD); GPIO_setPinConfig(GPIO_4_EPWM3A); GPIO_setPadConfig(5, GPIO_PIN_TYPE_STD); GPIO_setPinConfig(GPIO_5_EPWM3B); SysCtl_disablePeripheral(SYSCTL_PERIPH_CLK_TBCLKSYNC); initEPWM1(); initEPWM2(); initEPWM3(); SysCtl_enablePeripheral(SYSCTL_PERIPH_CLK_TBCLKSYNC); SysCtl_enablePeripheral((SysCtl_PeripheralPCLOCKCR)0x0011); CLB_enableCLB(CLB1_BASE); initTILE1(CLB1_BASE); // // Select Global input instead of local input for all CLB IN // CLB_configLocalInputMux(CLB1_BASE, CLB_IN0, CLB_LOCAL_IN_MUX_GLOBAL_IN); CLB_configLocalInputMux(CLB1_BASE, CLB_IN1, CLB_LOCAL_IN_MUX_GLOBAL_IN); CLB_configLocalInputMux(CLB1_BASE, CLB_IN2, CLB_LOCAL_IN_MUX_GLOBAL_IN); CLB_configLocalInputMux(CLB1_BASE, CLB_IN3, CLB_LOCAL_IN_MUX_GLOBAL_IN); CLB_configLocalInputMux(CLB1_BASE, CLB_IN4, CLB_LOCAL_IN_MUX_GLOBAL_IN); CLB_configLocalInputMux(CLB1_BASE, CLB_IN5, CLB_LOCAL_IN_MUX_GLOBAL_IN); CLB_configLocalInputMux(CLB1_BASE, CLB_IN6, CLB_LOCAL_IN_MUX_GLOBAL_IN); CLB_configLocalInputMux(CLB1_BASE, CLB_IN7, CLB_LOCAL_IN_MUX_GLOBAL_IN); CLB_configGlobalInputMux(CLB1_BASE, CLB_IN0, CLB_GLOBAL_IN_MUX_EPWM1_CTRDIR); CLB_configGlobalInputMux(CLB1_BASE, CLB_IN1, CLB_GLOBAL_IN_MUX_EPWM1_CTRDIR); CLB_configGlobalInputMux(CLB1_BASE, CLB_IN2, CLB_GLOBAL_IN_MUX_EPWM1A); CLB_configGlobalInputMux(CLB1_BASE, CLB_IN3, CLB_GLOBAL_IN_MUX_EPWM1B); CLB_configGlobalInputMux(CLB1_BASE, CLB_IN4, CLB_GLOBAL_IN_MUX_EPWM3A); // TEST CLB_configGlobalInputMux(CLB1_BASE, CLB_IN5, CLB_GLOBAL_IN_MUX_EPWM3B); //test CLB_configGlobalInputMux(CLB1_BASE, CLB_IN6, CLB_GLOBAL_IN_MUX_EPWM3_CTRDIR); //test CLB_configGlobalInputMux(CLB1_BASE, CLB_IN7, CLB_GLOBAL_IN_MUX_EPWM3_CTRDIR); //test // // Inputs set to GP register // CLB_configGPInputMux(CLB1_BASE, CLB_IN0, CLB_GP_IN_MUX_GP_REG); CLB_configGPInputMux(CLB1_BASE, CLB_IN1, CLB_GP_IN_MUX_GP_REG); CLB_configGPInputMux(CLB1_BASE, CLB_IN2, CLB_GP_IN_MUX_EXTERNAL); CLB_configGPInputMux(CLB1_BASE, CLB_IN3, CLB_GP_IN_MUX_EXTERNAL); CLB_configGPInputMux(CLB1_BASE, CLB_IN4, CLB_GP_IN_MUX_EXTERNAL); // TEST CLB_configGPInputMux(CLB1_BASE, CLB_IN5, CLB_GP_IN_MUX_EXTERNAL); // TEST CLB_configGPInputMux(CLB1_BASE, CLB_IN6, CLB_GP_IN_MUX_GP_REG); CLB_configGPInputMux(CLB1_BASE, CLB_IN7, CLB_GP_IN_MUX_GP_REG); CLB_setGPREG(CLB1_BASE, mode); CLB_setOutputMask(CLB1_BASE, 0x5, true); Interrupt_enable(INT_EPWM1); EINT; EPWM_setTimeBaseCounterMode(EPWM1_BASE, EPWM_COUNTER_MODE_UP); EPWM_setTimeBaseCounterMode(EPWM2_BASE, EPWM_COUNTER_MODE_UP); EPWM_setTimeBaseCounterMode(EPWM3_BASE, EPWM_COUNTER_MODE_UP); while(1) { asm(" NOP"); } } __interrupt void epwm1ISR(void) { EPWM_clearEventTriggerInterruptFlag(EPWM1_BASE); EPWM_clearEventTriggerInterruptFlag(EPWM3_BASE); // TEST Interrupt_clearACKGroup(INTERRUPT_ACK_GROUP3); CLB_setGPREG(CLB1_BASE, mode & 3UL); asm(" NOP"); } void initEPWM1() { EPWM_setTimeBasePeriod(EPWM1_BASE, EPWM1_TIMER_TBPRD); EPWM_setPhaseShift(EPWM1_BASE, 0U); EPWM_setTimeBaseCounter(EPWM1_BASE, 0U); EPWM_setSyncOutPulseMode(EPWM1_BASE, EPWM_SYNC_OUT_PULSE_ON_COUNTER_ZERO); EPWM_setCounterCompareValue(EPWM1_BASE, EPWM_COUNTER_COMPARE_A, EPWM1_CMPA); EPWM_setCounterCompareValue(EPWM1_BASE, EPWM_COUNTER_COMPARE_B, EPWM1_CMPB); EPWM_disablePhaseShiftLoad(EPWM1_BASE); EPWM_setClockPrescaler(EPWM1_BASE, EPWM_CLOCK_DIVIDER_1, EPWM_HSCLOCK_DIVIDER_1); EPWM_setCounterCompareShadowLoadMode(EPWM1_BASE, EPWM_COUNTER_COMPARE_A, EPWM_COMP_LOAD_ON_CNTR_ZERO); EPWM_setCounterCompareShadowLoadMode(EPWM1_BASE, EPWM_COUNTER_COMPARE_B, EPWM_COMP_LOAD_ON_CNTR_ZERO); EPWM_setActionQualifierAction(EPWM1_BASE, EPWM_AQ_OUTPUT_A, EPWM_AQ_OUTPUT_HIGH, EPWM_AQ_OUTPUT_ON_TIMEBASE_ZERO); EPWM_setActionQualifierAction(EPWM1_BASE, EPWM_AQ_OUTPUT_A, EPWM_AQ_OUTPUT_LOW, EPWM_AQ_OUTPUT_ON_TIMEBASE_UP_CMPA); EPWM_setActionQualifierAction(EPWM1_BASE, EPWM_AQ_OUTPUT_B, EPWM_AQ_OUTPUT_TOGGLE, EPWM_AQ_OUTPUT_ON_TIMEBASE_UP_CMPB); EPWM_setInterruptSource(EPWM1_BASE, EPWM_INT_TBCTR_ZERO); EPWM_enableInterrupt(EPWM1_BASE); EPWM_setInterruptEventCount(EPWM1_BASE, 3U); } void initEPWM2() { EPWM_setTimeBasePeriod(EPWM2_BASE, EPWM2_TIMER_TBPRD); EPWM_setPhaseShift(EPWM2_BASE, 0U); EPWM_setTimeBaseCounter(EPWM2_BASE, 0U); EPWM_enablePhaseShiftLoad(EPWM2_BASE); EPWM_setPhaseShift(EPWM2_BASE, 0U); EPWM_setCounterCompareValue(EPWM2_BASE, EPWM_COUNTER_COMPARE_A, EPWM2_CMPA); EPWM_setCounterCompareValue(EPWM2_BASE, EPWM_COUNTER_COMPARE_B, EPWM2_CMPB); EPWM_setClockPrescaler(EPWM2_BASE, EPWM_CLOCK_DIVIDER_1, EPWM_HSCLOCK_DIVIDER_1); EPWM_setCounterCompareShadowLoadMode(EPWM2_BASE, EPWM_COUNTER_COMPARE_A, EPWM_COMP_LOAD_ON_CNTR_ZERO); EPWM_setCounterCompareShadowLoadMode(EPWM2_BASE, EPWM_COUNTER_COMPARE_B, EPWM_COMP_LOAD_ON_CNTR_ZERO); EPWM_setActionQualifierAction(EPWM2_BASE, EPWM_AQ_OUTPUT_A, EPWM_AQ_OUTPUT_HIGH, EPWM_AQ_OUTPUT_ON_TIMEBASE_ZERO); EPWM_setActionQualifierAction(EPWM2_BASE, EPWM_AQ_OUTPUT_A, EPWM_AQ_OUTPUT_LOW, EPWM_AQ_OUTPUT_ON_TIMEBASE_UP_CMPA); EPWM_setActionQualifierAction(EPWM2_BASE, EPWM_AQ_OUTPUT_B, EPWM_AQ_OUTPUT_TOGGLE, EPWM_AQ_OUTPUT_ON_TIMEBASE_UP_CMPB); } void initEPWM3() // TEST { EPWM_setTimeBasePeriod(EPWM3_BASE, EPWM3_TIMER_TBPRD); EPWM_setPhaseShift(EPWM3_BASE, 0U); EPWM_setTimeBaseCounter(EPWM3_BASE, 0U); EPWM_setSyncOutPulseMode(EPWM3_BASE, EPWM_SYNC_OUT_PULSE_ON_COUNTER_ZERO); EPWM_setCounterCompareValue(EPWM3_BASE, EPWM_COUNTER_COMPARE_A, EPWM3_CMPA); EPWM_setCounterCompareValue(EPWM3_BASE, EPWM_COUNTER_COMPARE_B, EPWM3_CMPB); EPWM_disablePhaseShiftLoad(EPWM3_BASE); EPWM_setClockPrescaler(EPWM3_BASE, EPWM_CLOCK_DIVIDER_1, EPWM_HSCLOCK_DIVIDER_1); EPWM_setCounterCompareShadowLoadMode(EPWM3_BASE, EPWM_COUNTER_COMPARE_A, EPWM_COMP_LOAD_ON_CNTR_ZERO); EPWM_setCounterCompareShadowLoadMode(EPWM3_BASE, EPWM_COUNTER_COMPARE_B, EPWM_COMP_LOAD_ON_CNTR_ZERO); EPWM_setActionQualifierAction(EPWM3_BASE, EPWM_AQ_OUTPUT_A, EPWM_AQ_OUTPUT_HIGH, EPWM_AQ_OUTPUT_ON_TIMEBASE_ZERO); EPWM_setActionQualifierAction(EPWM3_BASE, EPWM_AQ_OUTPUT_A, EPWM_AQ_OUTPUT_LOW, EPWM_AQ_OUTPUT_ON_TIMEBASE_UP_CMPA); EPWM_setActionQualifierAction(EPWM3_BASE, EPWM_AQ_OUTPUT_B, EPWM_AQ_OUTPUT_TOGGLE, EPWM_AQ_OUTPUT_ON_TIMEBASE_UP_CMPB); EPWM_setInterruptSource(EPWM3_BASE, EPWM_INT_TBCTR_ZERO); EPWM_enableInterrupt(EPWM3_BASE); EPWM_setInterruptEventCount(EPWM3_BASE, 3U); }

  • Can you clarify one thing? you want EPWM3 to be generated by the CLB from the signals on EPWM1 and EPWM2 correct? If yes, then the code you sent is not correct. 

    Answer the question above and I will explain the process again!

  • Yes, it's almost that. I want EPWM3A to be generated by the CLB (as output) from the signals EPWM1A and EPWM1B (3A = High when 1A & 1B = HIGH).

    But I think, as you said to me, I can't set EPWM3 as output using CLB1, so I need to use XBARs right ?

    Thanks you again for your time !

    PS : Sorry for the last message, the code wasn't very clear, you can forget about EPWM2, I won't use it for now. And setting EPWM3 as an input was a mistake I think.