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.

Generating a PWM with tms570

Other Parts Discussed in Thread: HALCOGEN

Hi,

I´m new with the tms570 mcu development kit. I want to know how to generate a pwm signal and for example view it on the boards leds (nhet [0] or nhet [31] ).

There are some examples of pwm generations In the tms570ls manual but they are not in C, and are not finished.

I got an example in this forum, a zip named spraba0b -> "pwm example". But any of the leds blink on my board using this example.

 If you have some code example, user guide or steps for doing a PWM with the code composer studio and the TMS570, please tell me.

David

 

  • David,

    Welcome to TMS570LS series.

    I'm not sure I understand your comment about the fact that our PWM examples are not in C.

    To generate PWM, you can toggle an IO via software and interrupt, this is CPU consuming.

    In the TMS570LS Series, you have an hardware module named nHET that can do that for you, free of charge for the CPU.
    NHET is a kind of co-processor, executing is own program to realized timer function like Capture, Event count and of course PWM.

    I've attached a project for CCS V4 that used the nHET module to generate a 1hz pwm signal on HET0 pins.

    The project uses HALCOGEN to generate the device initialization and nHET initialization.
    You also found a project file for the nHET compiler and simulator.
    All this software tools are available on the installation DVD available with your kit, and can also be downloaded from the TMS570 page,

    Please let me know if this information will help you.

    Best Regards,

    Jean-Marc

    8372.HET_GUI_DEMO1.zip

  • Thanks Jean-Marc,

    I didn´t had any problems with your example and know I can better understand the nhet module and his configuration.

    Thank you very much.

    David

  • Only one more thing Jean-Marc,

    in the example that you give you said that the pin that has the pwm is the het0, but the led blinking on my board is the het31.

    In the configuration, it seems to be configurated as you said, like this: (in het.c)

     

     

     

     

     

     

    /* PWCNT: PWM 0 -> Duty Cycle

    * - Instruction = 1

    * - Next instruction = 2

    * - Conditional next instruction = 2

    * - Interrupt = 1

    * - Pin = 0

    */

    {

     

     

    /* Program */

    0x000055C0U,

     

     

    /* Control */

    (0x00004006U | (0U << 8U) | (3U << 3U)), //here I suppose that the 0U moved 8 positions refears to pin0. But as I have said, the blinky LED is the het31.

     

     

    /* Data */

    0x00000000U,

    Am I looking in the correct place?

  • David,

    The HET code is the file HET.C
    Here is an extract.

    const hetINSTRUCTION_t hetPROGRAM[] =
    {
          /* L00_0 */
        {
            0x00002C20,
            0x0004C4B2,
            0x00000000,
            0x00000000
        },

         /* L01_0 */
        {
            0x00004000,
            0x00404008,
            0x01312C80,
            0x00000000
        },

         /* L02_0 */
        {
            0x00001A00,
            0x00000000,
            0x00000000,
            0x00000000
        }
    };

    I've highlighted the control field for the ECMP instruction used on this code and I confirm that HET0 is the one blinking.
    I'm not sure what is the code you used in your previous post.

    Regards,

    Jean-Marc