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.

TMS320F28027: Trouble programming the PWM registers

Part Number: TMS320F28027
Other Parts Discussed in Thread: C2000WARE, DRV8353

Hi,

I'm trying to set up the PWM registers in the 2802, but they keep resetting to 0. If I try this manually with CCS in debug mode they all still revert to 0. Similarly for the ADC registers.

I can change the CPU core registers and the GPIO registers by the same method and these values stick. Can someone please assist?

oid init3ph(){
        volatile Uint32 *pwm1BaseAddr;
        volatile Uint32 *pwm2BaseAddr;
        volatile Uint32 *pwm3BaseAddr;
       // volatile Uint32 *pwm4BaseAddr;
        Uint16 regOffset;
        Uint16 reg_data;
        pwm1BaseAddr = (Uint32 *)0x6800;
        pwm2BaseAddr = (Uint32 *)0x6840;
        pwm3BaseAddr = (Uint32 *)0x6880;
      //  pwm4BaseAddr = (Uint32 *)0x68c0;

        EALLOW;
        // setup code goes here..
        //TBCTL
        regOffset = 0x00;
        reg_data = 0x0;
        pwm1BaseAddr[regOffset] = reg_data;
        pwm2BaseAddr[regOffset] = reg_data;
        pwm3BaseAddr[regOffset] = reg_data;
        //TBSTS tb Status
        regOffset = 0x01;
        reg_data = 0;
        pwm1BaseAddr[regOffset] = reg_data;
        pwm2BaseAddr[regOffset] = reg_data;
        pwm3BaseAddr[regOffset] = reg_data;
        //TBHSHR Extension for HRPWM Phase Register
        regOffset = 0x02;
        //TBPHS Time base Phase Register
        regOffset = 0x03;
        reg_data = 0;
        pwm1BaseAddr[regOffset] = reg_data;
        pwm2BaseAddr[regOffset] = 360;
        pwm3BaseAddr[regOffset] = 720;
        //TBCTR Time-Base Counter Register
        //TBPRD Time-Base Period Register
        regOffset = 0x03;
        reg_data = 1080;
        pwm1BaseAddr[regOffset] = reg_data;
        pwm2BaseAddr[regOffset] = reg_data;
        pwm3BaseAddr[regOffset] = reg_data;

}

  • Hi,

    Can you recheck the configuration that you've made?

    I see the flow like this in your code: TBCTL - 0, TBSTS - 0,  TBPHS - updated, TBPRD - updated 

    How are you configuring the PWM duty? By 'manually trying this with CCS in debug mode', do you mean you tried to update in the watch variables in CCS?

    Thanks,

    Aditya

  • I'm working from the example code in the 280027 technical reference manual, trying to generate a 3 phase sequence on gpio 0 -5.

    The code compiles and runs, BUT the PWM registers are not changed by the code. Trying to change them manually using either the register viewer or the memory viewer in CCS also does not work. It's not just the PWM registers - also the ADC fails to respond. It's almost like these sections of the processor are turned off, but there is nothing in the tech manual to say that this is the default state....

  • Are these the only configurations that you're making with respect to PWM? You can check the reference examples for epwm provided in C2000Ware located at <C2000Ware_3_04_00_00/device_support/f2802x/examples/struct>. You can take the initialization part of the code from those examples.

    Aditya

  • No: The point of the question is that I cannot program and read back the register values from any of the PWM's ADC and other peripherals. I can program the GPIO successfully.

    If I try and edit the registers (other than the GPIO and processor core) directly with CCS in debug mode, nothing happens either. The  processor  in question appears to be working correctly, as It works wit the Instaspin program. What I need to know is: Is this a problem with CCS or am I missing something to enable these peripherals before they can be programmed? So far it looks like the problem is with CCS - as there were many other errors in the files supplied for the F28002x processor.

  • Mike,

    Thanks for clarifying. I can suggest a couple of things to sort this out.

    1. What version of CCS are you using? (Although, it would be little unlikely for the problem to be in CCS version). You need not enable anything in CCS to run the program as long as you have the C2000 Support available (that's already there in your CCS, else building the code would also be an issue).

    2. You can use a reference example and try running that on your setup. Those examples are validated and should function as expected on the hardware.

    Also, you've marked the issue for device 'F28027' and you are mentioning about the files for 'f28002x'. Can you verify the device that you're using? There's an extra ZERO in the device numbers if you look closely! I hope that's not the issue. 

    Aditya

  • 1)

    Code Composer Studio
    Version: 10.4.0.00006

    OS: Linux, v.4.19.0-16-amd64, x86_64 / gtk 3.24.5
    Java version: 1.8.0_112

    2) I've tried three different examples for the F2802x, None of them compiled without fault, Lab05, lab01 and gpio_ex1 = which I've finally got to a stage where it will compile, load and run. However, ti programs the gpio, but then sits in an infinite loop waiting for a timer interrupt which it has disabled.

    3) The actual device is the F28027f supplied as part of the DRV8353 Eval kit. Needles to say I'm dissapointed at the amount of time I've spent not going very far with this.

    Mike.

    Finally some success:

    I managed to get the ADC Temp Sensor example to load and run - also can now edit tha ADC and PWM registers which I could not do before - I think there may have been confusion between 2802x and 28002x part numbers!!

    Mike.

  • I managed to get the ADC Temp Sensor example to load and run - also can now edit tha ADC and PWM registers which I could not do before - I think there may have been confusion between 2802x and 28002x part numbers!!

    The 28002x is a different class of device whose drivers obviously won't function on the f2802x. Glad that you fixed this. 

    Thanks,

    Aditya