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.

TMS570LC4357: N2HET capture signal doble period value few minutes after code execution.

Part Number: TMS570LC4357
Other Parts Discussed in Thread: LAUNCHXL2-570LC43, HALCOGEN

Tool/software:

Observe a strange behavior of N2HET device on LAUNCHXL2-570LC43.

In pooling mode, at rate 5 ms, it captured correct period value after boot. Then after 2 to 5 min, period value doble, and it continue in this state till you reset controller. Always repeatable for input square from 100 - 4 kHz.

What can be a reason?

N2HET code:

Assembly code from HET Ide:

; Use PCNT to measure period on 4 pins
L00 PCNT { type=FALL2FALL,pin=11,control=ON,period=0};
L01 PCNT { type=FALL2FALL,pin=16,control=ON,period=0};
L02 PCNT { type=FALL2FALL,pin=23,control=ON,period=0};
L03 PCNT { type=FALL2FALL,pin=31,control=ON,period=0};

; Used to wait for the next iteration of the loop
L04 BR { next=L00, cond_addr=L00, event=NOCOND};

HET_MEMORY const HET_INIT0_PST[5] = 
{ 

 	/* L00_0 */ 
	{
		0x00002E8B, 
		0x04000000, 
		0x00000000, 
		0x00000000
	}, 

 	/* L01_0 */ 
	{
		0x00004E90, 
		0x04000000, 
		0x00000000, 
		0x00000000
	}, 

 	/* L02_0 */ 
	{
		0x00006E97, 
		0x04000000, 
		0x00000000, 
		0x00000000
	}, 

 	/* L03_0 */ 
	{
		0x00008E9F, 
		0x04000000, 
		0x00000000, 
		0x00000000
	}, 

 	/* L04_0 */ 
	{
		0x00001A00, 
		0x00000000, 
		0x00000000, 
		0x00000000
	} 
};

Configuration:

Halcogen:

Generated:

void hetInit(void)
{
    /** @b initialize @b HET */

    /** - Set HET pins default output value */
    hetREG1->DOUT = (uint32)((uint32)0U << 31U)
                  | (uint32)((uint32)0U << 30U)
                  | (uint32)((uint32)0U << 29U)
                  | (uint32)((uint32)0U << 28U)
                  | (uint32)((uint32)0U << 27U)
                  | (uint32)((uint32)0U << 26U)
                  | (uint32)((uint32)0U << 25U)
                  | (uint32)((uint32)0U << 24U)
                  | (uint32)((uint32)0U << 23U)
                  | (uint32)((uint32)0U << 22U)
                  | (uint32)((uint32)0U << 21U)
                  | (uint32)((uint32)0U << 20U)
                  | (uint32)((uint32)0U << 19U)
                  | (uint32)((uint32)0U << 18U)
                  | (uint32)((uint32)0U << 17U)
                  | (uint32)((uint32)0U << 16U)
                  | (uint32)((uint32)0U << 15U)
                  | (uint32)((uint32)0U << 14U)
                  | (uint32)((uint32)0U << 13U)
                  | (uint32)((uint32)0U << 12U)
                  | (uint32)((uint32)0U << 11U)
                  | (uint32)((uint32)0U << 10U)
                  | (uint32)((uint32)0U << 9U)
                  | (uint32)((uint32)0U << 8U)
                  | (uint32)((uint32)0U << 7U)
                  | (uint32)((uint32)0U << 6U)
                  | (uint32)((uint32)0U << 5U)
                  | (uint32)((uint32)0U << 4U)
                  | (uint32)((uint32)0U << 3U)
                  | (uint32)((uint32)0U << 2U)
                  | (uint32)((uint32)0U << 1U)
                  | (uint32)((uint32)0U << 0U);

    /** - Set HET pins direction */
    hetREG1->DIR = (uint32) 0x00000000U
                 | (uint32) 0x00000000U
                 | (uint32) 0x00000000U
                 | (uint32) 0x00000000U
                 | (uint32) 0x00000000U
                 | (uint32) 0x00000000U
                 | (uint32) 0x00000000U
                 | (uint32) 0x00000000U
                 | (uint32) 0x00000000U
                 | (uint32) 0x00000000U
                 | (uint32) 0x00000000U
                 | (uint32) 0x00000000U
                 | (uint32) 0x00000000U
                 | (uint32) 0x00000000U
                 | (uint32) 0x00000000U
                 | (uint32) 0x00000000U
                 | (uint32) 0x00000000U
                 | (uint32) 0x00000000U
                 | (uint32) 0x00000000U
                 | (uint32) 0x00000000U
                 | (uint32) 0x00000000U
                 | (uint32) 0x00000000U
                 | (uint32) 0x00000000U
                 | (uint32) 0x00000000U
                 | (uint32) 0x00000000U
                 | (uint32) 0x00000000U
                 | (uint32) 0x00000000U
                 | (uint32) 0x00000000U
                 | (uint32) 0x00000000U
                 | (uint32) 0x00000000U
                 | (uint32) 0x00000000U
                 | (uint32) 0x00000000U;

    /** - Set HET pins open drain enable */
    hetREG1->PDR = (uint32) 0x00000000U
                 | (uint32) 0x00000000U
                 | (uint32) 0x00000000U
                 | (uint32) 0x00000000U
                 | (uint32) 0x00000000U
                 | (uint32) 0x00000000U
                 | (uint32) 0x00000000U
                 | (uint32) 0x00000000U
                 | (uint32) 0x00000000U
                 | (uint32) 0x00000000U
                 | (uint32) 0x00000000U
                 | (uint32) 0x00000000U
                 | (uint32) 0x00000000U
                 | (uint32) 0x00000000U
                 | (uint32) 0x00000000U
                 | (uint32) 0x00000000U
                 | (uint32) 0x00000000U
                 | (uint32) 0x00000000U
                 | (uint32) 0x00000000U
                 | (uint32) 0x00000000U
                 | (uint32) 0x00000000U
                 | (uint32) 0x00000000U
                 | (uint32) 0x00000000U
                 | (uint32) 0x00000000U
                 | (uint32) 0x00000000U
                 | (uint32) 0x00000000U
                 | (uint32) 0x00000000U
                 | (uint32) 0x00000000U
                 | (uint32) 0x00000000U
                 | (uint32) 0x00000000U
                 | (uint32) 0x00000000U
                 | (uint32) 0x00000000U;

    /** - Set HET pins pullup/down enable */
    hetREG1->PULDIS = (uint32) 0x00000000U
                    | (uint32) 0x00000000U
                    | (uint32) 0x00000000U
                    | (uint32) 0x00000000U
                    | (uint32) 0x00000000U
                    | (uint32) 0x00000000U
                    | (uint32) 0x00000000U
                    | (uint32) 0x00000000U
                    | (uint32) 0x00000000U
                    | (uint32) 0x00000000U
                    | (uint32) 0x00000000U
                    | (uint32) 0x00000000U
                    | (uint32) 0x00000000U
                    | (uint32) 0x00000000U
                    | (uint32) 0x00000000U
                    | (uint32) 0x00000000U
                    | (uint32) 0x00000000U
                    | (uint32) 0x00000000U
                    | (uint32) 0x00000000U
                    | (uint32) 0x00000000U
                    | (uint32) 0x00000000U
                    | (uint32) 0x00000000U
                    | (uint32) 0x00000000U
                    | (uint32) 0x00000000U
                    | (uint32) 0x00000000U
                    | (uint32) 0x00000000U
                    | (uint32) 0x00000000U
                    | (uint32) 0x00000000U
                    | (uint32) 0x00000000U
                    | (uint32) 0x00000000U
                    | (uint32) 0x00000000U
                    | (uint32) 0x00000000U;

    /** - Set HET pins pullup/down select */
    hetREG1->PSL = (uint32) 0x00000000U
                 | (uint32) 0x00000000U
                 | (uint32) 0x00000000U
                 | (uint32) 0x00000000U
                 | (uint32) 0x00000000U
                 | (uint32) 0x00000000U
                 | (uint32) 0x00000000U
                 | (uint32) 0x00000000U
                 | (uint32) 0x00000000U
                 | (uint32) 0x00000000U
                 | (uint32) 0x00000000U
                 | (uint32) 0x00000000U
                 | (uint32) 0x00000000U
                 | (uint32) 0x00000000U
                 | (uint32) 0x00000000U
                 | (uint32) 0x00000000U
                 | (uint32) 0x00000000U
                 | (uint32) 0x00000000U
                 | (uint32) 0x00000000U
                 | (uint32) 0x00000000U
                 | (uint32) 0x00000000U
                 | (uint32) 0x00000000U
                 | (uint32) 0x00000000U
                 | (uint32) 0x00000000U
                 | (uint32) 0x00000000U
                 | (uint32) 0x00000000U
                 | (uint32) 0x00000000U
                 | (uint32) 0x00000000U
                 | (uint32) 0x00000000U
                 | (uint32) 0x00000000U
                 | (uint32) 0x00000000U
                 | (uint32) 0x00000000U;

    /** - Set HET pins high resolution share */
    hetREG1->HRSH = (uint32) 0x00000000U
                  | (uint32) 0x00000000U
                  | (uint32) 0x00000000U
                  | (uint32) 0x00000000U
                  | (uint32) 0x00000000U
                  | (uint32) 0x00000000U
                  | (uint32) 0x00000000U
                  | (uint32) 0x00000000U
                  | (uint32) 0x00000000U
                  | (uint32) 0x00000000U
                  | (uint32) 0x00000000U
                  | (uint32) 0x00000000U
                  | (uint32) 0x00000000U
                  | (uint32) 0x00000000U
                  | (uint32) 0x00000000U
                  | (uint32) 0x00000000U;

    /** - Set HET pins AND share */
    hetREG1->AND = (uint32) 0x00000000U
                 | (uint32) 0x00000000U
                 | (uint32) 0x00000000U
                 | (uint32) 0x00000000U
                 | (uint32) 0x00000000U
                 | (uint32) 0x00000000U
                 | (uint32) 0x00000000U
                 | (uint32) 0x00000000U
                 | (uint32) 0x00000000U
                 | (uint32) 0x00000000U
                 | (uint32) 0x00000000U
                 | (uint32) 0x00000000U
                 | (uint32) 0x00000000U
                 | (uint32) 0x00000000U
                 | (uint32) 0x00000000U
                 | (uint32) 0x00000000U;

    /** - Set HET pins XOR share */
    hetREG1->XOR = (uint32) 0x00000000U
                 | (uint32) 0x00000000U
                 | (uint32) 0x00000000U
                 | (uint32) 0x00000000U
                 | (uint32) 0x00000000U
                 | (uint32) 0x00000000U
                 | (uint32) 0x00000000U
                 | (uint32) 0x00000000U
                 | (uint32) 0x00000000U
                 | (uint32) 0x00000000U
                 | (uint32) 0x00000000U
                 | (uint32) 0x00000000U
                 | (uint32) 0x00000000U
                 | (uint32) 0x00000000U
                 | (uint32) 0x00000000U
                 | (uint32) 0x00000000U;

/* USER CODE BEGIN (1) */
/* USER CODE END */

    /** - Setup prescaler values
    *     - Loop resolution prescaler
    *     - High resolution prescaler
    */
    hetREG1->PFR = (uint32)((uint32) 4U << 8U)
                | ((uint32) 0U);


   /** - Parity control register
    *     - Enable/Disable Parity check
    */
    hetREG1->PCR = (uint32) 0x00000005U;

    /** - Fill HET RAM with opcodes and Data */
    /** - "x" in "HET_INITx_PST" denote the HET module Instance
    *      Valid range of x - 0 to 9
    *      For HET1 module x = 0
    *      Refer HET assembler User guide for more Info
    */
    /*SAFETYMCUSW 94 S MR:11.1,11.2,11.4 <APPROVED> "HET RAM Fill from the table - Allowed as per MISRA rule 11.2" */
    /*SAFETYMCUSW 95 S MR:11.1,11.4 <APPROVED> "HET RAM Fill from the table - Allowed as per MISRA rule 11.2" */
    /*SAFETYMCUSW 95 S MR:11.1,11.4 <APPROVED> "HET RAM Fill from the table - Allowed as per MISRA rule 11.2" */
    (void)memcpy((void*)hetRAM1, (void*)HET_INIT0_PST, sizeof(HET_INIT0_PST));

    /** - Setup interrupt priority level */
    hetREG1->PRY = 0xFFFFFFFF;

    /** - Enable interrupts */
    hetREG1->INTENAC = 0xFFFFFFFFU;
    hetREG1->INTENAS = (uint32) 0x00000000U
                     | (uint32) 0x00000000U
                     | (uint32) 0x00000000U
                     | (uint32) 0x00000000U
                     | (uint32) 0x00000000U
                     | (uint32) 0x00000000U
                     | (uint32) 0x00000000U
                     | (uint32) 0x00000000U
                     | (uint32) 0x00000000U
                     | (uint32) 0x00000000U
                     | (uint32) 0x00000000U
                     | (uint32) 0x00000000U
                     | (uint32) 0x00000000U
                     | (uint32) 0x00000000U
                     | (uint32) 0x00000000U
                     | (uint32) 0x00000000U
                     | (uint32) 0x00000000U
                     | (uint32) 0x00000000U
                     | (uint32) 0x00000000U
                     | (uint32) 0x00000000U
                     | (uint32) 0x00000000U
                     | (uint32) 0x00000000U
                     | (uint32) 0x00000000U
                     | (uint32) 0x00000000U
                     | (uint32) 0x00000000U
                     | (uint32) 0x00000000U
                     | (uint32) 0x00000000U
                     | (uint32) 0x00000000U
                     | (uint32) 0x00000000U
                     | (uint32) 0x00000000U
                     | (uint32) 0x00000000U
                     | (uint32) 0x00000000U;


   /** - Setup control register
    *     - Enable output buffers
    *     - Ignore software breakpoints
    *     - Master or Slave Clock Mode
    *     - Enable HET
    */
    hetREG1->GCR = ( 0x00000001U 
                   | (uint32)((uint32)0U << 24U)
	               | (uint32)((uint32)1U << 16U)
                   | (0x00020000U));


/* USER CODE BEGIN (4) */
/* USER CODE END */

}

  • Hi Aleks,

    I am working on your issue now and will try to provide my update soon.

    If possible, can you please provide the complete project by zip it, if you do that i can directly debug your project and can provide my updates.

    --

    Thanks & Regards,
    Jagadish. 

  • Hi Jagadish,

    Unfortunately unable to provide you an application itself. If you need an additional information/tests please let me know. The goal of the HET is just measure period on 4 inputs and report to MCU at 5 ms rate.

  • Hi Aleks,

    Unfortunately unable to provide you an application itself. If you need an additional information/tests please let me know. The goal of the HET is just measure period on 4 inputs and report to MCU at 5 ms rate.

    Okay understood,

    But unfortunately, i didn't get enough time to work on your issue today. I will try to provide my updates by tomorrow.

    --
    Thanks & Regards,
    Jagadish.

  • Hi Aleks,

    I verified your HET code and i didn't find any issues in it. It looks fine for me.

    So, i should need to test this one to find out what went wrong.

    And i would like to know the following things for testing:

    1. Here you enabled 4 pins (pin-11, pin-16, pin23 and pin31) right, for which pins you are facing issue? Did you test with all the pins?

    2. And also need your application code, how you are reading and processing the captured data. If i get this then want to create similar project and want to verify the behavior.

    --
    Thanks & regards,
    Jagadish.

  • Hi Jagadish,

    1) 2 pins in use (16, 23) and 2 backup (11, 31). it doble values for 2 in use at the same time.

    2) data access in pull mode at rate 5 ms.

     

    #define LOOP_RES_TIME_NS 160.0
    #define NS_TO_SEC_RATIO 1000000000.0
    
    T_float32 frequency_hz = 0.0f;
    const HETPROGRAM0_UN * hetProgPtr = (HETPROGRAM0_UN*)hetRAM1;
    
    T_uint32 counter = hetProgPtr->Program0_ST.L01_0.pcnt.data;
    if(counter > 0)
    {
      period_s = counter * LOOP_RES_TIME_NS / NS_TO_SEC_RATIO;
      frequency_hz = (T_float32)(1.0 /period_s);
    }

    Thanks

  • Hi Aleks,

    I am trying to create a similar project, however my suggestion would be just trying to create one sample project from your end. This would be helpful for me to solve the issue easily.

    --
    Thanks & regards,
    Jagadish.

  • Hi Aleks,

    Based on your inputs i created one example project, and i didn't see any issues in the period and frequency measurements.

    First i want to explain what i am doing in my project:

    First i am generating a PWM signal using eTPWM module and i want to use this as input to our N2HET module. Here i am generating PWM signal with 1mS period.

    And i am creating RTI interrupt for every 1Sec, whenever i get this RTI interrupt then i want to print the capture period value to the SCI.

    So now i connected my generated PWM signal on D9 pin of the controller with the N2HET1[16] that is A4 controller. 

    And i did the testing for 15mins and i got the same values, i never see period double issue any time in testing:

    I always got period ~1ms and frequency 1Khz.

    In your case i am suspecting maybe it is an input issue, i am attaching my project for your reference. Can you please test this project and see whether you are getting the same issue or not?

    N2HET_capture_signal_double_period_Issue_LC4357.zip

    --
    Thanks & regards,
    Jagadish.

  • Hi Jagadish,

    I will test it an let you know about result.

    Regards

    Aleksey