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.

TMS570LS3137: TMS570LS3137

Part Number: TMS570LS3137

Tool/software:

I'm trying to generate PWM Signal on 2Pins but 2nd pin request im unable to generate In one pin i made but another pin not generating using HTURAM. het code mentioned below.

PWM_PERIOD .equ 4
PWM_PIN_NUM1 .equ 9 ; First PWM pin number
PWM_PIN_NUM2 .equ 10 ; Second PWM pin number
INIT_COMPARE1 .equ 2 ; Initial compare value for the first pin
INIT_COMPARE2 .equ 3 ; Initial compare value for the second pin
INIT_HR_DELAY .equ 120

; Counter instruction for generating the virtual counter
L00 CNT { reqnum=0,request=GENREQ,reg=A,irq=OFF,max=PWM_PERIOD};

; ECMP setup for the first PWM pin
L01 ECMP { next=L04,hr_lr=HIGH,en_pin_action=ON,cond_addr=L02,pin=PWM_PIN_NUM1,action=PULSELO,reg=A,irq=OFF,data=INIT_COMPARE1,hr_data=INIT_HR_DELAY};

; MOV32 instruction for the first pin
L02 MOV32 { remote=L01,type=IMTOREG&REM,reg=NONE,data=INIT_COMPARE1,hr_data=INIT_HR_DELAY};

; ECMP setup for the second PWM pin
L03 ECMP { next=L06,hr_lr=HIGH,en_pin_action=ON,cond_addr=L05,pin=PWM_PIN_NUM2,action=PULSELO,reg=A,irq=OFF,data=INIT_COMPARE2,hr_data=INIT_HR_DELAY};

; MOV32 instruction for the second pin
L04 MOV32 { remote=L03,type=IMTOREG&REM,reg=NONE,data=INIT_COMPARE2,hr_data=INIT_HR_DELAY};

; Branch to the next instruction
L05 BR { next=L00,cond_addr=L00,event=NOCOND};

; Branch back to the beginning of the PWM setup
L06 BR { next=L03,cond_addr=L03,event=NOCOND};

  • C code.

    //////////////////////////////////////////////////////////////////////////////////////////////////

    #define SINE_FREQ_DIVIDER 16 //5 //4.882 for 2KHz sine wave with LRP=64VCLK //16

    /* allowable LR Prescaler factors are 16, 32, 64 and 128. Anything less
    * than 32 will not have enough time slots for the N2HET program to
    * run.
    *
    *
    * LRPFC can be either 5, 6 or 7.
    * 7 -> one lr = 128 VCLK2
    * 6 -> one lr = 64 VCLK2
    * 5 -> one lr = 32 VCLK2
    * 4 -> one lr = 16 VCLK2
    */
    #define LRPFC 7 //6
    /* The pin number to output the sine wave signal */
    #define NHET1_PIN_PWM PIN_HET_4
    #define NHET1_PIN_PWM_1 PIN_HET_19

    /****************************************************************************/
    /* The PWM Period to be loaded to NHET1 CNT instruction. The minimum
    * PWM base frequency of the PWM is 1 * LRP */
    #define CNT_MAX_PERIOD 16U

    /* Number of sample points to digitize the SINE wave */
    #define SAMPLE_SIZE 1

    const UINT32 sine_table_percent[SAMPLE_SIZE]={1024};

    UINT32 sine_table[SAMPLE_SIZE];
    UINT32 sine_table_1[SAMPLE_SIZE];
    void htuInit(void);
    void configNHET1(void);
    void calculate_ecmp_compare(void);
    void hetInit(void);

    VOID APP_ModeValve_Init(VOID)
    {
    htuInit();

    hetInit();

    configNHET1();


    }


    void htuInit(void){
    /* DCP0 CPx element count = 1, frame count = SAMPLE_SIZE */
    htuRAM1 ->DCP[0].ITCOUNT = 0x00010000 + SAMPLE_SIZE;

    /* DCP0 CPx DIR = main memory to NHET */
    /* SIZE = 32-bit */
    /* ADDMH = 16 bytes */
    /* ADDFM = post-increment main memory */
    /* TMBA = circular buffer A */
    /* TMBB = one shot buffer B (buffer B not used) */
    /* IHADDR = 0x28 MOV32 data field */
    htuRAM1 ->DCP[0].IHADDRCT = (htuRAM1 ->DCP[0].IHADDRCT & 0x0) |
    0x1 << 23 | // DIR
    0x0 << 22 | // SIZE
    0x0 << 21 | // ADDMH
    0x0 << 20 | // ADDFM
    0x1 << 18 | // TMBA
    0x0 << 16 | // TMBB
    0x28 << 0; // IHADDR

    /* DCP0 CPA start address of source buffer */
    htuRAM1 ->DCP[0].IFADDRA = (unsigned int)sine_table;

    /* enable DCP0 CPA */
    htuREG1 ->CPENA = 0x00000001;

    /* enable HTU */
    htuREG1 ->GC = 0x00010000;
    }


    void configNHET1(void)
    {
    /* configure the LRP prescaler, the hr is always 1 and lr can be
    * either 16, 32, 64 or 128 */
    hetREG1->PFR = LRPFC << 8;

    /* calculate_ecmp_compare() will calculate the actual compare values
    * as well as the high resolution delay values for each sample point
    * of the same wave to be loaded into the NHET1 ECMP pin instructions */
    //calculate_ecmp_compare();

    sine_table[0]=1024;

    /* Enable DMA request on channel 0 of HTU. In the CNT instruction, the
    * DMA request is asserted to channel 0 of the HTU module */
    hetREG1->REQENS = 3 ;

    /* Set the selected pins to output. */
    hetREG1->DIR = (1 << NHET1_PIN_PWM) | (1 << NHET1_PIN_PWM_1);

    /* Load the PWM period based on the defined macro to the CNT instruction */
    hetRAM1->Instruction[pHET_L00_0].Control = (UINT32)(CNT_MAX_PERIOD - 1) |
    (hetRAM1->Instruction[pHET_L00_0].Control & 0xFFFD0000);

    /* Configure the pin numbers to output the PWM */
    hetRAM1->Instruction[pHET_L01_0].Control =
    (hetRAM1->Instruction[pHET_L01_0].Control & 0xFFFFE0FF) |
    (NHET1_PIN_PWM<< 8);

    hetRAM1->Instruction[pHET_L03_0].Control =
    (hetRAM1->Instruction[pHET_L03_0].Control & 0xFFFFE0FF) |
    (NHET1_PIN_PWM_1 << 8);

    //moved from hetinit


    hetREG1->GCR = 0x01030001U;
    }


    /* This function calculates the compare value and the high resolution delay
    * to be loaded into the NHET1 ECMP instruction for generating the PWM
    * DUTY cycle
    */
    void calculate_ecmp_compare(void)
    {
    UINT16 i=0;
    /* The number of sample points is fixed using SAMPLE_SIZE. The SINE
    * wave frequency is F = 1 / ((SINE_FREQ_DIVIDER * LRP) * Samples).
    * The way to generate a divided sine wave frequency is to increase
    * the PWM base frequency inversely. As we change the PWM base frequency
    * we also need to adjust the compare values to generate the PWM duty
    * cycle at each sine wave sample point.
    */
    for (i=0;i<=SAMPLE_SIZE;i++){
    /* CNT_MAX_PERIOD * 128 gives the total number of high resolution
    * clocks in one PWM_PERIOD. The multiplication is done by performing
    * a left shift of CNT_MAX_PERIOD by 7 bits.
    */
    sine_table[i] = (sine_table_percent[i] * (CNT_MAX_PERIOD << 7));
    }
    }

    void hetInit(void)
    {
    /** @b initialize @b HET */


    hetREG1->GCR = 0U;

    (void)memcpy((void*)hetRAM1, (void*)HET_INIT0_PST, sizeof(HET_INIT0_PST));

    // hetREG1->PFR = 0x309;

    /* Retain Pins - 8, 20, 21, 26, 29 as inputs for Voltage Monitoring */
    hetREG1->DIR = 0xFFFFFFFFU;

    /* Clear all Interrupt Flags */
    hetREG1->FLG = 0xFFFFFFFFU;

    /* Disable request lines */
    hetREG1->REQENS = 0x00000000U;

    /* NHET Request lines are not assigned to HTU */
    hetREG1->REQDS = 0x00;

    /* N2HET1 is configured as Master in continuous mode and turned on */
    // hetREG1->GCR = 0x01030001U;

    }

  • Hi Suguresh,

    Apologies for the delay in the late response.

    I am on leave for last week, so i got so many other issues to work on.

    Now i started working on this issue!

    I'm trying to generate PWM Signal on 2Pins but 2nd pin request im unable to generate In one pin i made but another pin not generating using HTURAM. het code mentioned below.

    I didn't understand this clearly.

    Please correct me if i am wrong:

    You are trying to generate two PWM signals on pin-9 and pin-10, but at the end the PWM is generating only on pin-9 and you can't be able to see the PWM signal on pin-10. Is it correct?

    --
    Thanks & regards,
    Jagadish.

  • Hi Suguresh,

    You are trying to generate two PWM signals on pin-9 and pin-10, but at the end the PWM is generating only on pin-9 and you can't be able to see the PWM signal on pin-10. Is it correct?

    Is this correct?

  • Actually i am giving for user for now we can take that scenario and i need to know for two signal i need to create 2 DCP and by giving the values from het ram i need to control 2 pwm signals.