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.

reset entry TPS 65381 init

Other Parts Discussed in Thread: HALCOGEN

Hi,

I am using the TMS 570 0332, CCS6.1 and halcogen 4.2.

 

I am trying to set up a Q and A wdog with the TPS chip.

I am able to initialize the TPS and set it to stay in the diagnostic mode.  However, when I re-initialize it so that the wdog starts, I am getting a reset entry somewhere in TPS_DriverInit().  I know I can communicate with the TPS chip and that the function works because it works the first time, sees the TPS chip is in the diagnostic state and returns from the function.

I am trying to follow the flow from a combination of the  safeTI example and the example from spna176a, but there are two main differences, I stripped out all the diagnostic stuff for now, and I am trying to run it from a task instead of using rti.

 

The line I am getting the reset entry on is in tpsWdgTask, TPS_DriverInit(&initstruct).  I tried stepping through the source, and I get the reset error on the following line from Tps_Driver.c

    while (TPS_DEVICE_DIAGNOSTIC != u8tps_device_state)
    {
        blRetVal = TPS_GetCurrentTPSDeviceState(&u8tps_device_state);
    }

My code: 

 

bool tpsInit()
{
	bool noErr = FALSE;

	TPS_Initilization_struct initstruct;

    /*initialize TPS driver*/
    initstruct.AMUXVoltageRailLimits = TPS65381Q_VoltageLimits;
    initstruct.GetTPSDiagPinSampledValue = NULL;
    initstruct.blNRES_Monitoring = TRUE;
    initstruct.blbist_at_startup = TRUE;
    initstruct.blenable_drv_op = TRUE;
    initstruct.blerror_pin_monitoring = FALSE;
    initstruct.blignition_power_latch = FALSE;
    initstruct.blsafe_state_timeout = TRUE;
    initstruct.dev_configreg_settings.blMASK_VBAT_OV = TRUE;
    initstruct.dev_configreg_settings.blMASK_VDD1_UV = TRUE;
    initstruct.dev_configreg_settings.blPOST_RUN_RST = TRUE;
    initstruct.dev_configreg_settings.blVDD3_5_OT = TRUE;
    initstruct.dev_configreg_settings.blVDD5_OT = TRUE;
    initstruct.error_pin_monitoring_mode = ERROR_PIN_MODE;
    initstruct.error_pin_pwm_width.u8PWM_HIGH = 8;
    /* the min error pin low duration in 204.8 us*/
    initstruct.error_pin_pwm_width.u8PWM_LOW = 40;
    initstruct.send_recieve_data_TPS = sendAndReceiveDataTPS;
    initstruct.u8pwd_threshhold_value = 5;
    initstruct.u8safe_lock_threshhold = 5;
    /* timeout duration in 198 ns*/
    initstruct.u8safe_state_timeout_scaler = 4;

	ulTPSTaskCheck[2] = OPEN_WINDOW_CONFIG/2;
	ulTPSTaskCheck[3] = OPEN_WINDOW_CONFIG/2+CLOSE_WINDOW_CONFIG/3;

    noErr = TPS_DriverInit(&initstruct);

    if (noErr == TRUE)
    {
    	noErr = TPS_SetMCUSoftwareDebugMode();
    }

    asm (" b #-8");

    return noErr;
}

void tpsWdgTask(void *params)
{

	volatile unsigned portLONG *pulTaskCheckVariable;
	uint8_t wdgFailCount;
	bool noErr = FALSE;
	/* The variable this task increments to show it is still running is passed
	in as the parameter. */
	pulTaskCheckVariable = ( unsigned portLONG * )params;
	TPS_WatchdoConfiguration watchdogconfig;

	noErr = TPS_DriverInit(&initstruct);
	if (noErr)
	{
		/*Initialize watchdog and open a new sequence run*/
		watchdogconfig.u8TokenFDBK = 0;
		watchdogconfig.u8TokenSeed = 0;
		watchdogconfig.blwatchdog_reset = TRUE;
		/* approx 40ms*/
		watchdogconfig.u8open_windowtime_scaler = (uint8) (OPEN_WINDOW_CONFIG / 0.55 - 1);
		/*approx 15 ms*/
		watchdogconfig.u8close_windowtime_scaler = (uint8) (CLOSE_WINDOW_CONFIG / 0.55 - 1);
		watchdogconfig.watchdog_mode = QANDA_MODE;
		noErr = TPS_WatchdogInit(&watchdogconfig);
	}

	if(noErr == FALSE)
	{
		//TODO handle the problem
	}

	( void ) params;
    while(1)
    {
    	( *pulTaskCheckVariable )++;
    	 noErr = TPS_GetWatchdogFailCount(&wdgFailCount);

    	if(wdgFailCount == 0)
    	{
    		switch (*(pulTaskCheckVariable+1))
    		{
    			case 0:
    			{
    				if(TPS_ConfigureWatchdogReset(TRUE))
    				{
    					(*(pulTaskCheckVariable+1))++;
    				}
    				TPS_ProtectConfigurationRegisters(LOCK);
    			}
    			break;

				case 1:
				{
					if(TPS_ExitDiagnosticMode())
					{
						(*(pulTaskCheckVariable+1))++;
					}
				}
				break;

				default:
				{
					//Don't do anything here
				}
				break;
			}
    	}

		TPS_UpdateActiveWDToken();
		TPS_SendWdgResponse(WD_TOKEN_RESP3);
		TPS_SendWdgResponse(WD_TOKEN_RESP2);
		TPS_SendWdgResponse(WD_TOKEN_RESP1);
		delay(*(pulTaskCheckVariable+3));
		TPS_SendWdgResponse(WD_TOKEN_RESP0);
		delay(*(pulTaskCheckVariable+2));
    }
}

  • Hello:

    We have received your post and we will get back to you soon.

    Regards.

  • Thanks...Are there any task based examples? The only (working) example I can find is installed with the SafeTI lib but is RTI based.

    I got around the reset issue by not calling the driverInit fn the second time. I don't think I need it since I haven't changed any configuration. As far as I know, calling TPS_WatchdogInit will configure the watchdog windows and start a new sequence.

  • No there are not task based examples.Yes Your understanding is correct.I could not get back to you on this soon as I was out of office.Sorry for the delay.

  • Thanks.

    I have two quick follow up questions.

    1) in the startup code that Halcogen it looks like there is a spot where it detects if it was reset from the nPORRST line, if this is connected to the TPS chip I should be able to use this to tell if the watchdog timer failed and caused a reset, correct?

    2) Aside from the system not resetting, is there a way I can know that the watchdog is being serviced and ok (ie a register from the tps I can read that will say the watchdog is ok)?

  • Hi,

    1) in the startup code that Halcogen it looks like there is a spot where it detects if it was reset from the nPORRST line, if this is connected to the TPS chip I should be able to use this to tell if the watchdog timer failed and caused a reset, correct?

    Manoj:Yes this else part  captures if the reset is external due to nRST being driven low.

        else
        {
            /* Reset caused by nRST being driven low externally.
            Add user code to handle external reset. */
    
    /* USER CODE BEGIN (23) */
    /* USER CODE END */
        }

    2) Aside from the system not resetting, is there a way I can know that the watchdog is being serviced and ok (ie a register from the tps I can read)?

    Manoj: You can use API TPS_GetWatchdogFailCount.In case you are not responding correctly to the watchdog this will return a non zero value indicating the number of times the watchdog has not been answered correctly.You can read the section on " Watchdog Token-Response Sequence Run and WDT_STATUS Register Updates" to know more on this.

    Hope my answers are helpful.


    Thanks and Best Regards

    Manoj

  • Thanks.It looks like it always shows a fail count of 5 and when I look at the state it shows I am in the reset state...that is probably at least part of my problem.

     

    I definitely get into and stay in the diagnostic state, but it looks like the call to TPS_WatchdogInit fails (returns 0).  I'll  look in to why.

    [EDIT] I have watchdogconfig.blwatchdog_reset set to TRUE, but in the example code it is set FALSE.  When I set this false I don't get the error from TPS_WatchdogInit, but  the fail count is always 5 and the tps device is in the reset state..

    If I want the TPS chip to cause a reset on a watchdog fail (count = 7) should this be set TRUE, or am I misunderstanding the purpose?

     

    Thanks for your help.

  • Hi,

    The TPS device causes reset on watchdog fail count of 7 and if watchdog reset is enabled.Probably you are trying to call TPS_WatchdogInit when the TPS device is not in the diagnostic state.Yes example code the watchdog reset was not enabled but nothing stops you from enabling it.You should work through some problems initially when setting up you watchdog handling thats it.

    Another thing. Every correct answer to the TPS devive reduces the fail count.When the transition from the diagnostic to active state happens the fail count is set to 5 and correct answers decrement this count and incorrect answers increment this count.Please go through the state diagram to understand this better.

    Let me know if you have more questions.

    Regards

    Manoj
  • Thanks for your reply, that matches my understanding. It is in the diagnostic state when I call the watchdog init function, but today it isn't resetting..

    I am seeing different behavior today than I was seeing yesterday. Yesterday I was seeing the fail count decrease, but today it is staying at 7, but I am in the active state.

    The flow I should be seeing is:
    - Initialize TPS driver (works OK)
    - Stay in diagnostic mode (works OK)
    - Service watchdog until fail count is 0 (seems to work OK)
    - Once the fail count is 0, exit diagnostic state (works OK)
    - service watchdog while in active state (not working).

    It looks like I am in the active state, but my fail count increases to 7, it isn't being serviced like it was in the diagnostic state. I will continue to investigate.

    Thanks for your help.