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.

TMS320F280025: TI AFE301 demo code to C2000Ware

Part Number: TMS320F280025
Other Parts Discussed in Thread: C2000WARE, AFE031

Hi

My project was developed under driverlab. I would like to know how to use a demo example boostxl_afe031_f28004x_pwmmode from TI to my C2000Ware project directly. Demo deme code is in bit field. You support is appreciated.

BR

HK Woo

  • Hi HK Woo,

    Since the project is in bit-field you can import one of the bit-field examples within C2000WARE for the F28002x to start (directory location below). Then make necessary changes, copy in source/header files, etc to port the project over to F28002x using bit-fields. Some additional porting effort, changes, and debugging may be necessary, but F28004x and F28002x devices are very similar.

    C:\ti\c2000\C2000Ware_4_00_00_00\device_support\f28002x\examples

    Porting to DriverLib would take a lot more effort.

    Best,

    Kevin

  • Hi

    Sorry. I don’t understand the procedures. Could you explain a little bit more. Thanks 

  • Hi HK Woo,

    Deeply sorry, I think I misunderstood your question. You already have a DriverLib project which you're wanting to add 'boostxl_afe031_f28004x_pwmmode' bit-field code to. Is this correct?

    If so, bit-field & driverlib approaches were designed in a way such that they can work together. Please see section 2.3 Project: Adding Bitfield or Driverlib Support in the document within C2000WARE below for details on how to add support for either to your project.

    C:\ti\c2000\C2000Ware_4_00_00_00\device_support\f28002x\docs\F28002x_FRM_EX_UG.pdf

    Because the 'boostxl_afe031_f28004x_pwmmode' project is for F28004x and not F28002x, there may be some additional changes that need to be made to the code. However they should be minor since F28004x and F28002x devices are very similar.

    Best,

    Kevin

  • Hi

    I followed the document. There is error message during compilation as below

    >> Compilation failure
    subdir_rules.mk:9: recipe for target 'f28002x_globalvariabledefs.obj' failed
    "../f28002x_globalvariabledefs.c", line 111: error #237: variable "CanaRegs" was declared with a never-completed type
    "../f28002x_globalvariabledefs.c", line 247: error #237: variable "Dcc0Regs" was declared with a never-completed type
    "../f28002x_globalvariabledefs.c", line 255: error #237: variable "Dcc1Regs" was declared with a never-completed type
    "../f28002x_globalvariabledefs.c", line 711: error #237: variable "LinaRegs" was declared with a never-completed type
    "../f28002x_globalvariabledefs.c", line 719: error #237: variable "LinbRegs" was declared with a never-completed type
    5 errors detected in the compilation of "../f28002x_globalvariabledefs.c".
    gmake: *** [f28002x_globalvariabledefs.obj] Error 1
    gmake: Target 'all' not remade because of errors.

    Please advise how to fix it. I am using C2000Ware 3.4

  • Hi

    I found other issue after I comment the variable in  order to move forwards the test.

    >> Compilation failure
    subdir_rules.mk:9: recipe for target 'hrpwm_ex3_prd_updown_sfo.obj' failed
    "C:\ti\c2000\C2000Ware_4_00_00_00\device_support\f28002x\headers\include\f28002x_lin.h", line 236: error #41: expected an identifier
    "C:\ti\c2000\C2000Ware_4_00_00_00\device_support\f28002x\headers\include\f28002x_lin.h", line 236: error #80: expected a type specifier
    "C:\ti\c2000\C2000Ware_4_00_00_00\device_support\f28002x\headers\include\f28002x_lin.h", line 236: error #170: a function type is not allowed here
    "C:\ti\c2000\C2000Ware_4_00_00_00\device_support\f28002x\headers\include\f28002x_lin.h", line 236: warning #109-D: signed bit field of length 1
    3 errors detected in the compilation of "../hrpwm_ex3_prd_updown_sfo.c".
    gmake: *** [hrpwm_ex3_prd_updown_sfo.obj] Error 1
    Building file: "syscfg/board.c"

    The error is due to a structure name SCIFIR_BITS in f28002x_lin.h which has a bit definition "IDLE" and it is same in cpu.h of driverlib however, they are different definition.

    struct SCIFLR_BITS {                    // bits description
        bp_16 BRKDT:1;                      // 0 Break-detect Flag (SCI compatible mode)
        bp_16 WAKEUP:1;                     // 1 Wake-up Flag
        bp_16 IDLE:1;                       // 2 SCI receiver in idle state (SCI compatible mode)
        bp_16 BUSY:1;                       // 3 Busy Flag
        bp_16 TIMEOUT:1;                    // 4 LIN Bus IDLE timeout Flag (LIN only)
        bp_16 rsvd1:1;                      // 5 Reserved
        bp_16 TOAWUS:1;                     // 6 Timeout After Wakeup Signal Flag (LIN only)
        bp_16 TOA3WUS:1;                    // 7 Timeout After 3 Wakeup Signals Flag (LIN only)
        bp_16 TXRDY:1;                      // 8 Transmitter Buffer Ready Flag
        bp_16 RXRDY:1;                      // 9 Receiver Buffer Ready Flag
        bp_16 TXWAKE:1;                     // 10 SCI Transmitter Wakeup Method Select
        bp_16 TXEMPTY:1;                    // 11 Transmitter Empty Flag
        bp_16 RXWAKE:1;                     // 12 Receiver Wakeup Detect Flag
        bp_16 IDTXFLAG:1;                   // 13 Identifier On Transmit Flag (LIN only)
        bp_16 IDRXFLAG:1;                   // 14 Identifier on Receive Flag
        bp_16 rsvd2:1;                      // 15 Reserved
        bp_32 rsvd3:8;                      // 23:16 Reserved
        bp_32 PE:1;                         // 24 Parity Error Flag
        bp_32 OE:1;                         // 25 Overrun Error Flag
        bp_32 FE:1;                         // 26 Framing Error Flag
        bp_32 NRE:1;                        // 27 No-Response Error Flag (LIN only)
        bp_32 ISFE:1;                       // 28 Inconsistent Sync Field Error Flag (LIN only)
        bp_32 CE:1;                         // 29 Checksum Error Flag (LIN only)
        bp_32 PBE:1;                        // 30 Physical Bus Error Flag (LIN only)
        bp_32 BE:1;                         // 31 Bit Error Flag (LIN only)
    };

    Definition of IDLE in cpu.h

    #ifndef _DUAL_HEADERS
    #ifndef IDLE
    #define IDLE  __asm(" IDLE")
    #endif
    #else
    #define IDLE_ASM __asm(" IDLE");
    #endif

    It is conflict.  Of course, it can be rename to different name but I don't know any negative result. I find a _DUAL_HEADER. I google and found that it is for project where bitfield and driverlib are using but I don't know what is a best way to define it in project property.

    Please advise how to fix it.

    BR

    HK Woo

  • Hi HK Woo,

    You need to add the _DUAL_HEADER pre-defined symbol to your CCS project, per the document referenced earlier.

    When combining bit-field and driverlib support, add a pre-defined symbol within the project properties
    called "_DUAL_HEADERS". This is required to avoid having conflicting definitions (in
    enums/structs/macros) which share the exact same names in both bit-field and driverlib headers.

    Steps are the following:

    Right click project in Project Explorer --> Select Properties --> Build --> C2000 compiler --> Predefined Symbols --> Add '_DUAL_HEADER'

    Best,

    Kevin

  • Hi Kevin

    I still have a problem to port the code from F28004x to F28002x.

    I got error as below during compile.

    subdir_rules.mk:9: recipe for target 'hrpwm_ex2_prdupdown_sfo_v8.obj' failed
    "../hrpwm_ex2_prdupdown_sfo_v8.c", line 285: error #137: struct "PCLKCR0_BITS" has no field "HRPWM"
    "../hrpwm_ex2_prdupdown_sfo_v8.c", line 306: error #137: struct "TBCTL_BITS" has no field "SYNCOSEL"

    It is due to below code

    1.    CpuSysRegs.PCLKCR0.bit.HRPWM = 1;

    2.     EPwm1Regs.TBCTL.bit.SYNCOSEL = TB_SYNC_DISABLE;

    I checked  PCLKCR0 which is refer to struct PCLKCR0, however there is no HRPWM  bit

    struct PCLKCR0_BITS {                   // bits description
        Uint16 rsvd1:1;                     // 0 Reserved
        Uint16 rsvd2:1;                     // 1 Reserved
        Uint16 DMA:1;                       // 2 DMA Clock Enable bit
        Uint16 CPUTIMER0:1;                 // 3 CPUTIMER0 Clock Enable bit
        Uint16 CPUTIMER1:1;                 // 4 CPUTIMER1 Clock Enable bit
        Uint16 CPUTIMER2:1;                 // 5 CPUTIMER2 Clock Enable bit
        Uint16 rsvd3:7;                     // 12:6 Reserved
        Uint16 CPUBGCRC:1;                  // 13 CPUBGCRC Clock Enable Bit
        Uint16 rsvd4:2;                     // 15:14 Reserved
        Uint16 HRCAL:1;                     // 16 HRCAL Clock Enable Bit
        Uint16 rsvd5:1;                     // 17 Reserved
        Uint16 TBCLKSYNC:1;                 // 18 EPWM Time Base Clock sync
        Uint16 rsvd6:1;                     // 19 Reserved
        Uint16 rsvd7:4;                     // 23:20 Reserved
        Uint16 ERAD:1;                      // 24 ERAD module clock enable
        Uint16 rsvd8:7;                     // 31:25 Reserved
    };

    I check the TBCTL which is belong to struct TBCTL_BITS, however there is no SYNCOSEL bit

    struct TBCTL_BITS {                     // bits description
        Uint16 CTRMODE:2;                   // 1:0 Counter Mode
        Uint16 PHSEN:1;                     // 2 Phase Load Enable
        Uint16 PRDLD:1;                     // 3 Active Period Load
        Uint16 rsvd1:2;                     // 5:4 Reserved
        Uint16 SWFSYNC:1;                   // 6 Software Force Sync Pulse
        Uint16 HSPCLKDIV:3;                 // 9:7 High Speed TBCLK Pre-scaler
        Uint16 CLKDIV:3;                    // 12:10 Time Base Clock Pre-scaler
        Uint16 PHSDIR:1;                    // 13 Phase Direction Bit
        Uint16 FREE_SOFT:2;                 // 15:14 Emulation Mode Bits
    };

    Please advice how to resolve it.

    THanks

    HK Woo

  • Hi HK Woo,

    As I mentioned earlier, there will be some minor changes to be made when porting to F28002x. You should take some time to understand the device differences (such as ePWM/HRPWM modules) and review the respective TRM sections.

    Peripheral differences between the C2000 devices are documented at a high level in the reference guide below:

    https://www.ti.com/lit/spru566

    You'll see for F28002x, and newer devices, that the HRPWM has the change "Clocks to individual HRPWM modules would be hooked up to the respective ePWMs."

    Please review the C2000WARE examples in the directory below for further understanding of SW config:

    C:\ti\c2000\C2000Ware_4_00_00_00\device_support\f28002x\examples\hrpwm

    Best,

    Kevin

  • Hi Kevin

    Thanks for your advance. However, I still have a problem about how to generate 143.75Khz and 131.25Khz using HRPWM. I import the bitfield example hrpwm_ex2_prdupdown_sfo_v8.

    I modified below code

    1.HRPWM_Config(20) to HRPWM_Config(347)

    2.(*ePWM[1]).TBPRDHR = 211U << 8; //211 << 8 is a code in F28004x AFE301 PWM MODE, it is after item 1

    3. status = SFO(); //after #2, I don't know SFO() is necessary or not. I don't see it in code of F28004x

    4. I comment all code in first level for loop.

    However, 143.75KHz still cannot generated.

    What is my problem?

  • Hi HK Woo,

    1.HRPWM_Config(20) to HRPWM_Config(347)

    This function does more than just change the period and compare values. Why not use the portion of code from the original example for this portion? I think it's just the clocking mechanisms that are different between the F28002x and F28004x PWM modules.

    Fullscreen
    1
    2
    3
    4
    EPwm6Regs.TBPRD = 347;
    EPwm6Regs.TBPRDHR = (211U << 8);
    EPwm6Regs.CMPA.bit.CMPA = EPWM1A_SPACE_COMPARE; // Set compare A value
    EPwm6Regs.CMPB.bit.CMPB = EPWM1B_SPACE_COMPARE; // Set Compare B value
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

    3. status = SFO(); //after #2, I don't know SFO() is necessary or not. I don't see it in code of F28004x

    SFO is used in F28004x code as well, but maybe differently. Do a search i the project for SFO.

    Best,

    Kevin