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.

PWM implementation on N2HET

Hello. You could advise a method of implementation of output of PWM of a signal from the N2HET module. Thus that start would be carried out from the main program, the given quantity of the periods of PWM stood out (for example 10), further stopped, before receiving the following signal of start. What command it is possible to pause and launch N2HET if the controler works in Functional mode (nTRST signal = 0)

  • Thanks for the post i am assigning the post to our SME. who will get back to you on the topics.

     

    Regards,

    Hercules forum support

  • Sergey,

    Hi, sorry I'm having a little trouble understanding the question(s) so if I don't get the question right please ask again.

    For just trying to understand how to use N2HET to generate a PWM, I would suggest starting with the HET IDE:  http://www.ti.com/tool/het_ide

    This tool includes a simulator and examples of functions like PWM that you can execute and step through to get a better understanding of how HET works. With the simulator you can see internal states (like registers) that are not visible on actual silicon,  this makes learning N2HET a lot easier on the HET IDE. When you open HET IDE,  select "Tools->Algorithm Library" and you'll get a GUI that includes sample pieces of HET code that you can paste into your own HET program and simulate.   Make sure to look at the "Standard Output examples" tab and you'll see that there are about 8 different PWM examples currently.

    If you want to put a counter around the PWM such that a certain number of pulses are generated each time the CPU triggers the N2HET, then you can take one of the examples and add some code that jumps around the PWM code (so N2HET doesn't execute the PWMs) unless another counter is nonzero.   I've done this by preceding the code with a few lines like:

    START   SUB   {src1 = IMM, src2 = ZERO, dest=NONE, data=0, hr_data=0}
                   BR    {event=NZ, cond_addr= TBASE1}

               ... Otherwise do something else....

    TBASE1 would be the start of your PWM instructions,  so they would only execute if the data field at address "START" is nonzero.

    To kick off a number of PWM periods, the host CPU would write a value like '10' to START.   You would also add add an "ADD" instruction into your code that adds 'ONES" to the value in START each time a period matches.   (i.e. adds -1,  essentially decrementing START's data field each time a PWM period matches.).

    When your PWM code has hit the period match "N" times, where "N" is the # that the CPU wrote to START's data field, the code will stop branching to TBASE1 and stop executing the PWM code until the CPU writes to the START field again to trigger a new set of pulses.

    If you want to HALT the host CPU and the N2HET whenever such a condition matches, you'll need to have the conditional structure embedded in your code because breakpoints in N2HET are simple, unconditional ones.   You can only break on a certain instruction being executed.   So make sure you've got an instruction in your program that is only branched to whenever the condition you are interested in matches, and then set a breakpoint on that instruction by editing the program field in a code-composer studio memory window.  You need to set bit 22 of the program field to have the N2HET halt when it reaches this instruction.  The N2HET will also normally halt the host CPU as well.   Section 19.2.1.7 of SPNU499 has instructions on how to use the breakpoint capability of N2HET.   It is a very 'manual' process that involves poking into RAM in CCS and so I try to use the HET IDE for all my debugging until I absolutely need to use Silicon.

    Best Regards,

    -Anthony