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.

How to make the C6747 EHRPWM module to work?

Other Parts Discussed in Thread: CCSTUDIO, TMS320C6747, OMAP-L137, AM1808

Hello,

I'm trying to  operate the C6747 EHRPWM peropheral as 4 independent PWM channels (2 channels on EPWM0, 2 channels on EPWM1).

Unfortunately, it did not work.

Looking at the EPWM0 registers I noticed that the counter of the PWM does not advance.

I verified that the SYSCLK2 is activated (PLLDIV2=0x8001). So the 150 MHz SYSCLK2 is supposed to be there.

I did call

           Psc_ModuleClkCtrl(Psc_DevId_1, PSC_LPSC_eHRPWM, TRUE); /* PSC_LPSC_eHRPWM=17 */ to enable the PWM clock.

The TBCTL value is set to 0xA038, so it is supposed to run as up counter.

Is there any source code example how to use the EHRPWM peripheral?

  • Hi,

    I've the same problem. The TBCTR is not running.
    I would also be interessted in an code example...

    joe

  • I will try to dig up (or create) a simple example today.

  • Please see the project in the attached .zip file. This is a basic EHRPWM setup project used to configure and then enable the EHRPWM timer. You should be able to see the EHRPWM0 TBCNT register incrementing at address 0x01F00008. This project was built using the cslr from PSP 1.20.00.

    Note: When building this project with PSP 1.20.00 I received 5 separate redefintion warnings from inside the cslr_ehrpwm.h file. I am not yet sure if these have been filed as bugs or fixed in a newer version, but you should be able to ignore these for the purpose of this example.

    *edit* You can ignore the intvecs.asm file. I did not mean to leave that in the project folder. Fixed PSP version numbers.

    *second edit* I ripped the PLL/PSC configuration straight from the GEL file so this is not as clean as it could be code-wise.

    C6747_EHRPWM_example.zip
  • Hi Tim,

    Thanks for your example. Starting the timers in the system config register was the missing key.

    One important point is "missing" in your example. Before starting the timers (SyscfgRegs->CFGCHIP1 = CSL_FMKT(SYSCFG_CFGCHIP1_TBCLKSYNC, ENABLE)) there should be an unlock of the system config registers.

       l_SyscfgRegs->KICK0R = 0x83E70B13;    // unlock system config registers
       l_SyscfgRegs->KICK1R = 0x95A4F1E0; 

       SyscfgRegs->CFGCHIP1 = CSL_FMKT(SYSCFG_CFGCHIP1_TBCLKSYNC, ENABLE);

       l_SyscfgRegs->KICK0R = 0x00;    // lock multiplexing registers
       l_SyscfgRegs->KICK1R = 0x00;

    Otherwise it will not take the activation setting. With the example project it will work, because there are the system config registers left unlocked (accidentally?) in the Setup_PLL() method.

    joe

  • Joe,

    Thank you for pointing this out. As I mentioned I ripped the other peripheral init code straight out of the GEL and did not bother to clean it up in favor of getting working PWM init code out sooner. I plan on adding to my code example (some interrupt processing and cleaning up the init code) when I get back from vacation next week. Until then hopefully what I've already written is enough to get you on your way... [:)]

  • Hi everyone,

    I recently released an EHRPWM example on the Embedded Processors Wiki. This example was built to demonstrate how to initialize the EHRPWM module and service EHRPWM interrupt events. The ISR simply increments or decrements the CMPA value so as to shift the output left or right until a boundary is hit.

    Hopefully this example is of use! Feedback is always welcome, either here or on the Wiki page itself.

  • hi, Tim, thank you for posting the example.  I have a fundamental questions.  I tried to compile the file, and got an error message that "C6747_EHRPWM_example.c", line 2: fatal error: could not open source file "ti/pspiom/cslr/csl.h".  I noticed that actually the csl.h file is already included in the project.  What is the reason for include it as "ti/pspiom/cslr/csl.h"

    - Sean

  • Sean,

    Sean Huang said:
    I have a fundamental questions.  I tried to compile the file, and got an error message that "C6747_EHRPWM_example.c", line 2: fatal error: could not open source file "ti/pspiom/cslr/csl.h".  I noticed that actually the csl.h file is already included in the project.  What is the reason for include it as "ti/pspiom/cslr/csl.h"
    The CSL/PSP examples use this include schema, so I went ahead and used it in my project as well. All this means is you have to point the project to the root directory where the /ti/pspiom/cslr folder is located. If you do not have your PSP folder installed in the same location as mine you will need to update the include path in the Project->Build Options. If you have installed the PSP in Program Files which is the default you may only need to change the version number in the include search path.

    Let me know if you get hung up on this.

  • Hi, Tim,

    Thank you for your response.  I did found "cslxxx.h" and other "cslrxxx.h" files in my computer.  However, they are installed under the folders such as "C:\CCStudio_v3.3\ndk_2_0_0_0\packages\ti\ndk\src\hal\evmomapl137\eth_omapl137\inc".  Sometimes one header file includes another header file, which may reside into another folder. I don't know if I have installed the software correctly.  Could you tell me the name of the PSP setup.exe file?  I used the default directory patch, and they install files at several different folders.  I'm confused to understand the difference.  I'm thinking to reinstall everything into one folder, but worries I have to change the Build Options again.  Any suggestions?

    TMS320F2533x MCU provides example codes such as "C2833x/C2823x C/C++ Header Files and Peripheral Examples (SPRC530 )".  Does OMAP-L137 or TMS320C6747 have any similar example codes available?  Thank you.

  • I used the CSLr from PSP 1.20.00 as indicated on my Wiki article. You can find this PSP installer here. By default this is installed in C:\Program Files which is where my project should point.

  • Tim, thank you for the prompt response.  Let me try the PSP on my machine.  - Sean

  • These postings were also helpful for AM1808 Sitara processors. Documentation doesn't list chip config registers very clearly.