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.

HET setup for sin table plus external /internal triggering

Other Parts Discussed in Thread: TMS570LS20216-EP

I am trying to setup the HET of a TMS570LS20216-EP very similar to the sin generation example (spna217).

But I also want to trigger a set of ADC readings and an external pin at a particular point on the sin output pattern.

e.g. If the sin table is 128 samples, at sample 125 I trigger the ADC to take three samples and once complete or at another fixed point (lets say sample 127) I want to toggle an external pin high for a single sample period (or shorter).

I'd want to interrupt when the ADC is complete, so could generate the external pin change in the interrupt routine to guarantee the ADC had completed.

How would I program the HET to generate these two synchronisation signals along with the sin output?

One way I'd thought of achieving this is to have three tables of samples, 1-Sin, 2-ADC trigger, 3-Output

But having two 128 word tables with just two words non-zero seems wasteful.

Is there a better way of doing this using HET instructions?

  • Hello Ian,

      I think you can extend the Sine Wave NHET program to generate an event at sample 125 to the ADC so the the ADC will start conversion. You can also generate an interrupt when the sample 127 is reached so CPU can set a GIO pin in the ISR. When the ADC conversion completes, it also generates an interrupt to the CPU. In the ADC completion ISR, you will clear the GIO.

     Since NHET is a coprocessor, there are multiple ways to write the software. Below is just one example. Below example assumes 12 samples per sine wave. So each sample is equal to 30 degrees on the sine wave. This example will assert NHET1[8] pin at the 8th sample. NHET1[8] is internally connected to ADC1 as one of the conversion event inputs. Please check the datasheet of your device for available trigger inputs to the ADC. You can extend the program to cover other scenarios.

    PWM_PERIOD            .equ 11
    PWM_PIN_NUM           .equ 9
    INIT_COMPARE          .equ 6
    INIT_HR_DELAY         .equ 0
    ADC_TRIGGER_PIN       .equ 18
    SAMPLE_TO_TRIGGER     .equ 7

    L00   CNT { reqnum=0,request=GENREQ,reg=A,irq=OFF,max=PWM_PERIOD};
    L01   ECMP { next=L03,hr_lr=HIGH,en_pin_action=ON,cond_addr=L02,pin=PWM_PIN_NUM,
                 action=PULSELO,reg=A,irq=OFF,data=INIT_COMPARE,hr_data=INIT_HR_DELAY};
    L02   MOV32 { remote=L01,type=IMTOREG&REM,reg=NONE,data=INIT_COMPARE,hr_data=INIT_HR_DELAY};

    ; Only execute the below instructions when Z flag is detected. Z flag is set
    ; when one PWM is complete. One PWM period means one sample point in the sine wave.
    L03   BR { next=L06,cond_addr=L04,event=Z};
    L04   CNT { next=L05,reg=B,max=PWM_PERIOD,data=0};
    L05   ECMP { next=L06,en_pin_action=ON,cond_addr=L06,pin=ADC_TRIGGER_PIN,action=PULSEHI,reg=B,data=SAMPLE_TO_TRIGGER, hr_data=0};
    L06   BR { next= L00, cond_addr=L00, event= NOCOND }

     

  • Hi Charles,

    Thanks for the example. Just what I was looking for.
    I'm new to using the N2HET, so I'm still trying to get my head around use cases, it's starting to make sense now!

    Regards,
    Ian.