A very simple HET example: Project1 - generate 2 PWM signals and simulate them with Synapticad Wave Viewer.

In the previous posts I reviewed a HET application note called HET Getting Started. This time I use another application note called HET Getting Started. That one is for the TI TMS470 family but works perfectly with the TMS570/RMxx too. It's simpler, using a few lines to generate two PWMs with same frequency and different duty cycle.

Ideal to show a simulation with Synapticad's WaveViewer - an application that you can use without cost and that integrates with the HET IDE.


You should read the previous post - it 'll help to understand the timer code below.



HET Code and Output Signals


Here's the HET code that generates the two PWMs. Line L00 is the frequency control, L01 and L02 the duty cycle managers, L03 the end of the program.


L00: CNT {next=L01, reg=A, irq=OFF, max=0x214A, data=0}  

; PWM (50% duty cycle)  
L01: ECMP {next=L02, reg=A, hr_lr=LOW, en_pin_action=ON, pin=CC4, action=PULSEHI, irq=Off,  data=0x10A5}  
; PWM (25% duty cycle)  
L02: ECMP {next=L03, reg=A, hr_lr=LOW, en_pin_action=ON, pin=CC6, action=PULSEHI, irq=Off,  data=0x852}  

L03: BR {next=L00, cond_addr=L00, event=NOCOND}  


The settings in the HET IDE and HALCoGen:


The resulting signals measured on HET pins 4 and 6:


HET Getting Started App Note - scope trace


Simulating the HET Logic


In the HET IDE, the output pins are marked. I've also asked to export register A because that's used in the logic of lines L00 -> L03



Program is assembled, loaded, and we let it execute (I've let it run 12000 VCL2 ticks).

You can see the HET PFR register with the pre-scalers right under.


Once the IDE has executed the steps, it automatically loads another application, Synapticad Wave Viewer Free.

(The next 12 days it's called Synapticad Wave Former on my laptop. I've applied for a 15 day trial license that enables generating inputs and stimuli.)


Below you can see the landing page.I've zoomed out so that you can appreciate the HR vs LR clock, the code line counter and the location of pin 4 and 6.

Click to enlarge. All other captures below are zoom-ins and outs of the same stimulation.



Below you can see that when the zero flag ticks (L00 has reached its count), both pins 4 and 6 start a cycle.


At that same moment (this is a zoom in of the above point), register A starts over from 0. (that's what caused the z-flag to be raised).

The het loop count keeps on counting. It's the number of loops we've simulated.


The next two captures are the L01 and L02 events.

When register A reaches the compare of L01, it kicks pin 4 high. This happens at the loop resolution clock tick, because we set the hr_lr attribute to low.


The same for line L02, but at a different time (when register A reaches 0x10A5):


That's it. As usual, the Code Composer Studio, HALCoGen and HET projects are attached to the post.


Related Blog
1: adapt TI example to a LaunchPad
2: Generate Dynamic Duty Cycle
3: Measure a PWM Signal and HET Interrupts
4: Getting Started
5: Getting Started with the Wave Form Simulator