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.

TMS570LS3137: ICU edge detection and signal measurement

Part Number: TMS570LS3137

Hi ,

I am using AUTOSAR MCAL drivers in my project. I have a question regarding ICU driver usage.

I need to detect the edges and create a notification function for an ICU channel. Also, I need to measure duty cycle and requency from the same ICU channel.

In the EBTresos, I could select the measurement type only either as ICU_MODE_SIGNAL_EDGE_DETECT or ICU_MODE_SIGNAL_MEASUREMENT. 

I need to clarify that is it possible to measure edges, frequency and duty cycle together if I select the measurement type as ICU_MODE_SIGNAL_EDGE_DETECT?

If not, what are other ways to detect all these 3 parameters for an ICU channel.

  • Hi,

    No.  

    1. Edge detection uses ECNT instruction. Please refer to N2HET instruction set in TRM

    2. Signal measurement (duty, Period): use PCNT instruction. Please refer to N2HET instruction set in TRM

    This is my example of 5 ICU channel: channel 0, 1, and 4 are edge detection, and channel 2 is signal measurement:

    Those are instructions (highlighted) used for those 5 ICU channels: The 1st/2nd/5th channel's OPCOD (12~9 bit) is 1010 (ECNT), and the OPCODE for 3rd channel: is 0111 (PCNT)

  • Hi,

    No.  

    1. Edge detection uses ECNT instruction. Please refer to N2HET instruction set in TRM

    2. Signal measurement (duty, Period): use PCNT instruction. Please refer to N2HET instruction set in TRM

    This is my example of 5 ICU channel: channel 0, 1, and 4 are edge detection, and channel 2 is signal measurement:

    Those are instructions (highlighted) used for those 5 ICU channels: The 1st/2nd/5th channel's OPCOD (12~9 bit) is 1010 (ECNT), and the OPCODE for 3rd channel: is 0111 (PCNT)

  • Hi,

    What will be the results from the API Icu_GetDutyCycleValues in case if the corresponding ICU channel measurement type is selected as ICU_MODE_SIGNAL_EDGE_DETECT? 

  • Hello,

    You have to give the valid channel number which is configured in Measurement Mode 'Signal Measurement, Duty Cycle Values'. Otherwise, error will be returned.

  • Hi QJ,

    I need to generate edge detection notification for every falling edge. I could see an option to configure the notification functions during edge detection. But, there is no specific option to select the generation for falling edges. Please let me know the parameters to configure to generate notification for falling edges. 

  • Hello,

    The interrupt is generated for the event (yellow highlighted) defined in "IcuDefaultStartEdge". If you select "falling edge", the interrupt will be generated at falling edge.

  • Hi Qj,

    Edge notifications are not working in my software. I am giving PWM signals to the ICU pin (connected to N2HET1 module) and expecting the edge notification functions to be triggered for every falling edge but the notification functions are not getting called. Below are my configuration settings, 

    1.  Notification function is configured in the Tresos tool for falling edges.Inside this notification function, I am counting the edges
    2.  N2HET1 level 1 interrupt ( Interrupt source 24 as per data sheet) is configured as CATEGORY 2 and enabled in OS
    3.  ISR "Icu_HetInt" is mapped to N2HET1 level 1 interrupt
    4.  Below API's are called,
    • Icu_SetActivationCondition()
    • Icu_EnableEdgeDetection()
    • Icu_EnableNotification()

    During debugging, I observed that the interrupt function "Icu_IrqFunction()" is not getting triggered and my edge counters are not updating as well.Can you please check my settings and confirm the steps are correct?

     

  • Can you check if IRQ interrupt is enabled in CPSR register, and if N2HET1 VIM channel is enabled in VIM REQMASKSETx register?

  • Hi QJ,

    I changed the interrupt source of ICU driver from N2HET1 level 1 interrupt ( Interrupt source 24) to N2HET1 level 0 interrupt ( Interrupt source 10). Now, the edge interrupts are working.

    I dont understand the reason why it was not working with N2HET1 level 1 interrupt ( Interrupt source 24). Can you please explain?

  • The N2HET interrupt priority is not configurable in MCAL driver, and is hard-coded as below:

    HET_PRY(RegBaseAddress) = 0x0000FFFFU;

    Channels 0 to 15 are priority level 0 (High level), 16 to 31 are priority level 1 (Low level). The ICU ECNT instructions are located between channel 0 and 15. 

    Thanks and Regards,
    QJ Wang

  • I have configured NHET20 as an ICU pin. As per your comment, this pin is mapped to priority level 1 interrupt because it falls under channel 16-31. 

    But during testing, I found level 1 interrupts are not working for this channel. Only level 0 interrupts are working. Why?

  • Hello,

    My coworker just reminded me that this restriction is also included in the PWM_Driver_userguide: