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.

CCS/TMS570LS1224: nhet instruction meaning

Part Number: TMS570LS1224
Other Parts Discussed in Thread: HALCOGEN

Tool/software: Code Composer Studio

Hi

I generated pwm code by HAL but I couldnot understand the meaning of these two lines

hetRAM->Instruction[(pwm << 1U) + 41U].Control = ((hetRAM->Instruction[(pwm << 1U) + 41U].Control) & (~(uint32)(0x00000018U))) | (action << 3U);
hetRAM->Instruction[(pwm << 1U) + 41U].Data = (((pwmPeriod * pwmDuty) / 100U) << 7U) + 128U;

Please explain what is happening and how are the shift operators used.

Why does pwmduty has to be left shifted by 7 and then why 128 is added

Also in control setting, why is action shifted left 3 bits and why 18 is OR with action

  • Hi Rajat,

    These are instructions used in the pwmSetDuty function for example. HALCoGen uses a template High-End-Timer (HET) program and then customizes it based on the user configuration of PWMs and input captures.

    Consider the set of instructions for PWM1 as an example. This is a set of 4 instructions:

    CNT

    PWCNT

    DJZ

    MOV64

    The instruction at (1<<1 + 41) is instruction number 43, which is the MOV64 instruction corresponding to PWM1. Now look at the "control" field of the MOV64 instruction in the TRM.

    The control field is first read, then AND'ed with ~(0x18) and then OR'ed with the selected "action". This essentially is a read-modify-write operation that only updates the "Action" in the above control field.

    Now consider the data field of the MOV64 instruction:

    This data field is made up or a 7-bit high-resolution data field and a 25-bit loop-resolution data field. This HALCoGen example does not use the high-resolution capability, so the "HR Data" field is not used. This is why the updated data value is shifted by 7 and then an offset of 128 is added (2^7 = 128).

    Hope this helps.

    Regards, Sunil