IDE : s32ds for platform v3.5
MCU : s32k324
here i want to use delay function by for 100ms for that i want to use OsIf but in configuration side i'm face issue, that screenshort i atteched below
please share example code for configuration osif and use delay function
or step for this procedure from configuration and which API will need.
please share in details so that i can easily understand and it will benificial for other more developers
解決済! 解決策の投稿を見る。
You can implement the following code changes in a Siul2_Port_Ip_Example_S32K344 to blink a led:
#define TIME_TYPE OSIF_COUNTER_SYSTEM
void OsIfDelay(uint32 timeoutMs);
void OsIfDelay(uint32 timeoutMs)
{
uint32 curTime = 0u;
uint32 endTime = 0u;
uint32 timeoutCnt = 0u;
curTime = OsIf_GetCounter(OSIF_COUNTER_SYSTEM);
timeoutCnt = OsIf_MicrosToTicks(timeoutMs * 1000u, TIME_TYPE);
while(1)
{
endTime += OsIf_GetElapsed(&curTime, TIME_TYPE);
if(timeoutCnt <= endTime)
{
break;
}
}
}
/**
* @brief Main function of the example
* @details Initialize the used drivers and uses the OsIf
* drivers to toggle a LED.
*/
int main(void)
{
Siul2_Port_Ip_Init(NUM_OF_CONFIGURED_PINS_PortContainer_0_BOARD_InitPeripherals, g_pin_mux_InitConfigArr_PortContainer_0_BOARD_InitPeripherals);
OsIf_Init(NULL);
Siul2_Dio_Ip_WritePin(LED_Q172_PORT, LED_Q172_PIN, 1U);
while(1)
{
OsIfDelay(1000);
Siul2_Dio_Ip_TogglePins(LED_Q172_PORT, 1 << LED_Q172_PIN);
}
}
Best regards,
Julián
In order to use the TimerClockRef, you need to add the Mcu module in the MCAL layer, which will generate the clock reference point:
If you have no need for the MCAL layer, you can also add the "TimerClockFreq" input:
The default frequency for the system timer is 48MHz. You can use the "OsIf_Init(NULL)" function to initialize the module, and the APIs included in "OsIf_Timer.c" to create a delay function:
Best regards,
Julián
thank you @Julián_AragónM Julián_AragónM for reasponse
i done configuration for that i added Mcu module in MCAL Layer so got McuClockRefpoint.
now as you say using this API i can write delay function
i'm trying to write function but not getting clearity. do you have example code or screenshort then please share here otherwise guide me
You can implement the following code changes in a Siul2_Port_Ip_Example_S32K344 to blink a led:
#define TIME_TYPE OSIF_COUNTER_SYSTEM
void OsIfDelay(uint32 timeoutMs);
void OsIfDelay(uint32 timeoutMs)
{
uint32 curTime = 0u;
uint32 endTime = 0u;
uint32 timeoutCnt = 0u;
curTime = OsIf_GetCounter(OSIF_COUNTER_SYSTEM);
timeoutCnt = OsIf_MicrosToTicks(timeoutMs * 1000u, TIME_TYPE);
while(1)
{
endTime += OsIf_GetElapsed(&curTime, TIME_TYPE);
if(timeoutCnt <= endTime)
{
break;
}
}
}
/**
* @brief Main function of the example
* @details Initialize the used drivers and uses the OsIf
* drivers to toggle a LED.
*/
int main(void)
{
Siul2_Port_Ip_Init(NUM_OF_CONFIGURED_PINS_PortContainer_0_BOARD_InitPeripherals, g_pin_mux_InitConfigArr_PortContainer_0_BOARD_InitPeripherals);
OsIf_Init(NULL);
Siul2_Dio_Ip_WritePin(LED_Q172_PORT, LED_Q172_PIN, 1U);
while(1)
{
OsIfDelay(1000);
Siul2_Dio_Ip_TogglePins(LED_Q172_PORT, 1 << LED_Q172_PIN);
}
}
Best regards,
Julián