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.

TMS570LS0914: How to use N2HET to monitor a variable cycle and variable duty pluse

Part Number: TMS570LS0914
Other Parts Discussed in Thread: HALCOGEN

Tool/software:

Hello, Guys:

Now I have used TMS570LS0914 to monitor a input signal, Which cycle and duty are variable.
I want use N2HET to detect the max high level times (500uS) and the max duty (40%), and the min level times Tmin > 2us.
So, I want the N2HET code can detect high level times and signal duty, When the high level time > 500uS or Signal duty > 40%
then the N2HET code issued a interruput to CPU.

So please give me some idea about this case.

thanks!! 

  • Now I am use PCNT to captruer high level and period of the pluse, but i don't know how to use the captruered data to calculating the duty of signal in N2HET code.

  • Done by myself for refer PWM monitor demo

  • Hi Kerhac,

    If you are using HALCoGen generated code for PWM capture in NHET, then there could be a possible of one loop resolution period error in the captured data.

    The reason for this is, i explained in the below thread:

     (2) TMS570LS3137: PWM Capturing Code is working incorrectly - Arm-based microcontrollers forum - Arm-based microcontrollers - TI E2E support forums

    And in above i also mentioned a method to reduce the loop resolution, that is using of HET IDE code instead of HALCoGen generated code.

    If you want, you can proceed with above method.

    However today i also did one more method to improve the accuracy in the measurement using HALCoGen generated code itself, that is High Resolution method.

    Actually, there can be do the two kind of generation or measurements will be possible using N2HET, one is Loop resolution and other one is high resolution.

    Actually, after verifying HALCoGen genrated code for capturing i found that we are using PCNT instruction for capturing of period and duty cycle.

    Using this instruction, we can also do the high-resolution measurement because this will also increase the 7-bit HR field.

    But if you verify the HALCoGen generated capture API, there we are not using this 7bit capture data, instead of we are only using Loop resolution data.

    As you can see, we are just right shifting the data and calculating the period and duty cycles.

    This is a simple method you can use this method for low frequency measurements, i mean where the one loop resolution error is don't matter.

    But if you want to measure high frequencies then you should either go for HET IDE generated code that i already mentioned or you can use below method.

    In this method i created a new API called HR_CapGetSignal, in this API i am not ignoring the 7-bit HR data as well for accurate measurement.

    I followed the method given for HR data in the TRM.

    And here is the test results:

    Result while using capGetSignal:

    As you can see i applied 10uS input waveform for capturing and i got the measured period as 9.38uS this is because we knew that one loop resolution error could be possible and here the loop resolution is 833uS.

    And here is the output when i used HR_CapGetSignal API:

    As you can see now the 10uS is measured as 9.9999uS, which is so accurate.

    I am attaching my tested project for your reference, please go through it:

    PWM_Capturing_With_High_Resolution_LC4357.zip

    --
    Thanks & regards,
    Jagadish.