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.

TMS570 HET PWM Program

Hi,

I am using the TMS570 Microcontroller Development Stick, with a TMS570LS20216 MCU (ASPGEQQ1).

I have downloaded the example program from "NHET-AppNote_spraba0b.pdf" URL: http://www-s.ti.com/sc/techlit/spraba0.zip. This appears to be working fine, except that the frequency is slightly wrong.

The example uses the following NHET code:

L00: CNT{next = L01, reg = A, max = 624}
L01: MCMP{next = L00, reg = A, en_pin_action = ON, hr_lr=HIGH, pin = CC10, action
PULSEHI, order = REG_GE_DATA, data = 0x1D4, hr_data = 0x60}

(I am using HET pin 10, rather than 0 in the example, because this pin is available on the development stick)

The NHET clock VCLK2 is 50MHz. HR is 1, so HRP should be 20ns and LR is 8 so LRP should be 160ns.

According to the literature the number of high-resolution clock cycles in one PWM period is:

HRC_pwm = (CNT_max + 1) × lr = (624 + 1) × 8 = 5000
As the period HRP is 20ns, this should give a period of 100microseconds and the frequency should be 10,000Hz.

I am getting 10.66kHz on my scope, rather than 10kHz

If I change the max value in the program to 500, the equation above would suggest that the frequency should be 12.5kHz, but the scope shows 13.3kHz.

Any ideas what might be wrong?

Regards,

Dave

 

  • The problem with the code is that the frequency was set up to 53.33 MHz instead of 50 MHz.

    In system.c

    the code should be changed from:

        systemREG1->PLLCTL1 =  0x00000000U
                            |  0x20000000U
                            | (2U << 24U)
                            |  0x00000000U
                            | (5U << 16U)
                            | (119U  << 8U);

    to:

        systemREG1->PLLCTL1 =  0x00000000U
                            |  0x20000000U
                            | (2U << 24U)
                            |  0x00000000U
                            | (7U << 16U)
                            | (149U  << 8U);

    This corrects the VCLK2 to 50MHz and then the output frequency is right.

    Regards,
    Dave

  • Thanks for posting the solution to this Dave.