Hi!
I'm using S32K312 for a project and I want to create a timer using the sysTick. I have chosen the configuration like the following:
Use System Timer - checked
Operating System Type - Baremetal
Core Frequency - 48000000
Now I'm using the OsIf_Timer_System_Internal_GetCounter() to get the systemTick for next processing of timer.
My timer code module file looks like this:
*! \file
*
* \brief SW Timer implementation
*
* \author
*
* This module makes use of a System Tick in millisconds and provides
* an abstraction for SW timers
*
*/
/*
******************************************************************************
* INCLUDES
******************************************************************************
*/
#include "OsIf.h"
#include "timer.h"
#include "rfal_platform.h"
/*
******************************************************************************
* LOCAL DEFINES
******************************************************************************
*/
/*
******************************************************************************
* LOCAL VARIABLES
******************************************************************************
*/
static uint32_t timerStopwatchTick;
/*
******************************************************************************
* GLOBAL FUNCTIONS
******************************************************************************
*/
/*******************************************************************************/
//uint32_t timerCalculateTimer( uint16_t time )
uint32_t timerCalculateTimer( uint32_t time )
{
//uint32_t timeValue = OsIf_MicrosToTicks(((uint32_t)time*1000),OSIF_COUNTER_SYSTEM);
uint32_t timeValue = (uint32_t)time;
return ( platformGetSysTick() + timeValue);
}
/*******************************************************************************/
bool timerIsExpired( uint32_t timer )//100 //300
{
uint32_t uDiff;
int32_t sDiff;
uDiff = ((timer - platformGetSysTick())); /* Calculate the diff between the timers */
sDiff = uDiff; /* Convert the diff to a signed var */
/* Having done this has two side effects:
* 1) all differences smaller than -(2^31) ms (~25d) will become positive
* Signaling not expired: acceptable!
* 2) Time roll-over case will be handled correctly: super!
*/
/* Check if the given timer has expired already */
if( sDiff < 0 )
{
return true;
}
return false;
}
/*******************************************************************************/
//void timerDelay( uint16_t tOut )
void timerDelay( uint32_t tOut )
{
uint32_t t;
/* Calculate the timer and wait blocking until is running */
t = timerCalculateTimer( tOut );
while( timerIsRunning(t) ); //#define timerIsRunning(t) !( timerIsExpired( uint32_t timer ))
}
/*******************************************************************************/
void timerStopwatchStart( void )
{
timerStopwatchTick = platformGetSysTick();
}
/*******************************************************************************/
uint32_t timerStopwatchMeasure( void )
{
return (uint32_t)(platformGetSysTick() - timerStopwatchTick);
}
This code file is a part of ST NFC sw drop, and we have to adapt to the NXP environment.
platformGetSysTick() macro is there for OsIf_Timer_System_Internal_GetCounter().
I was trying to use the timerDelay() to get 1 ms delay, but whatever I do provide as an argument to this function, I'm always getting 100ms as a delay. I'm trying to get LED_High and LED_Low and trap the change in CRO.
RTD: AUTOSAR_2.0.0
SDK: PlatformSDK_S32K3_2022_03_S32K312_M7
I need some suggestion, how to tackle this issue.