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.

TMDSRM48HDK: N2HET Capture timestamp of event (rising or falling edge)

Part Number: TMDSRM48HDK
Other Parts Discussed in Thread: HALCOGEN

Hi I am trying to capture the falling edge of an input signal and record the time when the falling edge is received using the N2HET timer module. Using capGetSignal(), I can only get the duty cycle and period. Is there any way to get the timestamp when the edge was received? I do not want to have an interrupt handler to capture the timestamp.

  • Hi Smruthi,

    The HET program generated by HALCoGen does include two functions hetResetTimestamp and hetGetTimestamp. These work only with pin 0 and is not configurable using the HALCoGen GUI. The timestamp is captured using a WCAP instruction with an "ALWAYS" condition selected. You can modify this instruction in your application to choose the appropriate pin number and pin condition which you want to timestamp. The WCAP instruction is instruction number 57 in the HET program generated by HALCoGen (the last instruction in the program).

    I recommend developing HET code using the HET IDE: http://www.ti.com/tool/HET_IDE

    This would allow you to better implement the HET program you want in an optimal way.

    Regards, Sunil

  • Hi Sunil,

    Thanks for the suggestion. My question is how do I run the code generated by HET IDE in CCS? I did write a code in HET IDE and import it into Halcogen. I just wanted to know how to execute that in CCS?

  • Hi Smruthi,

    The HET IDE generates a .c and a .h file for your HET program. You can add these files to your CCS project. There are a few application notes that are available online that include HET programs created using the HET IDE, and which include a complete CCS project to demonstrate the highlighted functionality.

    For example, see this app note: http://www.ti.com/lit/an/spna217/spna217.pdf

    The pdf includes a link to the .zip file for the CCS project.

    Regards, Sunil

  • Hi Sunil,

    One more question, is it possible to use the interrupts enabled by Halcogen while using the HET IDE code for the N2HET timer? This is because I want to generate a pwm interrupt at the end of every period while capturing another signal and getting the timestamp of the falling edge of that signal and compare the timestamps of both. Or how do we generate a PWM end of duty interrupt in HET IDE? 

    Regards,

    Smruthi

  • Hi Smruthi,

    You can certainly configure and use interrupts using HALCoGen. I am having trouble understanding the use case, and would appreciate more clarification.

    Several HET instructions can generate interrupts when the associated condition matches, e.g. ECMP (Equality Compare) instruction can generate an interrupt when the selected register's contents matches its data field. You have flexibility to define when to generate the interrupt depending on how you choose to implement the PWM generation.

    Regards, Sunil

  • Hi Sunil,

    So what I am trying to do is to fire a PWM interrupt at the end of the period and measure the counter when the PWM duty ended as well as when the input ignal is captured. So I have a HET IDE program that is capturing the counter value for the signals. When I enable interrupts in Halcogen after I have loaded the HET IDE code, I am not able to generate interrupts that I selected in Halcogen for the N2HET timer module. So I just wanted to ask if there is a way to get Halcogen generated interrupts to work even after enabling the HET IDE source code in Halcogen for the N2HET timer? Or how do  generate end of PWM period interrupts in the HET IDE?

    Reagrds,

    Smruthi Ramesh

  • Hi Smruthi,

    HALCoGen allows you to enable / map two separate interrupts from the N2HET, one considered a higher-level interrupt and the second a lower-level interrupt. The higher-level interrupt is mapped to a lower numbered interrupt channel by default.

    Sources for these interrupts are the HET program instructions and can be decoded by the interrupt service routine based on the interrupt index offset value read from the HETOFFx register. See section 20.2.7 in RM48x reference manual on page 821.

    Regards, Sunil

  • Hi Sunil,

    I am able to generate interrupts on Halcogen. But if I enable the Advanced Config Mode(Disable black box driver) in N2HET, then the I am unable to generate PWM interrupts which I enabled through the Halcogen GUI. Do you think I am doing something incorrectly?

    Regards,

    Smruthi

  • Actually I figured out what my mistake is. Thanks

  • Hi Sunil,

    One more question. How do you convert the counter value captured by WCAP into time (in seconds). 

    Does the counter store the loop counts? If yes then what does 1 loop count correspond to in terms of time?

    Regards,

    Smruthi Ramesh

  • Hi Smruthi,

    The WCAP instruction has a 32-bit data field, of which 25 bits reflect the loop-resolution (LR) count and the lower 7 bits reflect the high-resolution (HR) count. The high-resolution clock counter is optional and depends on whether the feature is enabled inside the WCAP instruction.

    The HR count is based on the high-resolution clock period, which is divided down from the VCLK2 period. Loop count is based on the loop-resolution clock period, which is divided down from the high-resolution clock.

    Both the HR and LR periods are defined by the configuration of the HET Prescale Factor register (HETPFR). See the section titled "Time Base" in the HET chapter of the TRM.

    Regards,

    Sunil