I have configure the FreeRTOS with low power tickless ideal mode (used MPLAB Harmony) with LIN slave .I have configured 3 application task , They running independently, don’t have any blocking state/events. I have to go to sleep when no communication ( no data) on LIN bus for 1 sec & wake up again once communication started. I used timer to monitor the LIN bus. The timer interrupts (1s) is occur when no communication on LIN & calling vPortSuppressTicksAndSleep (). I written own function vPortSuppressTicksAndSleep() calling inside PM_StandbyModeEnter().
but controller not going to sleep . Can any one help here?
Next step is to check if there are any pending interrupts or other tasks that are preventing the device from going to sleep. Try commenting out interrupts and tasks and see if you can narrow down the issue.
What @tony-josi-aws meant to ask is to share your implementation of vPortSuppressTicksAndSleep. Does the default implementation of vPortSuppressTicksAndSleep work for you?
Thanks for reply.
yes default implementation of vPortSuppressTicksAndSleep not work.
before own implementation , I am directly calling vPortSuppressTicksAndSleep(2) but not work , microcontroller not going to sleep. hence I write own implementation of vPortSuppressTicksAndSleep,check below but it also not work (i am not sure how to stop systick , as well below code may wrong) :
void vPortSuppressTicksAndSleep( TickType_t xExpectedIdleTime )
{
Your implementation of vPortSuppressTicksAndSleep is not disabling the interrupts. Ideally, vPortSuppressTicksAndSleep should be called by the IDLE task when no task is ready to execute, which would program the systick timer to interrupt after the xExpectedIdleTime has elapsed or another interrupt (likey external) has tiggered.
Is it possible for you to make your other tasks blocking based on the status of the LIN bus so that the IDLE task can take care of putting your device to tickless sleep mode?
Sure , I can make other 3 tasks blocking based on the status of the LIN bus but how & which is good way (mutex, semaphore etc) to block other task. Could you share me examples & where should i put PM_StandbyModeEnter() ?
Thank you Gaurav, i used xEventGroupWaitBits & its working fine. Now if any interrupt is come i need to set the events hence all task again start to run.
now one issue is that when all called xEventGroupSetBits(xEventGroup,ALL_TASK_WAKE_UP_EVENT); inside configPOST_SLEEP_PROCESSING it prevent to go to sleep. Not sure how to solve it ?
check below implementation of 3 task. When is LIN timeout occurs ,need to clearing the eventsBits for blocking the all task and set the eventBits to run the all tasks when one or many interrupts occur .
The code you shared seems incomplete. Does the following describe correctly what you want to achieve:
lLINTASK_Tasks waits for LIN_TASK_WAKE event bit. When LIN_TASK_WAKE is set, it wakes up lREADINGLAMP_Tasks and lPWMTASK_Tasks by setting corresponding bits.
If the above is correct, you need to change the xEventGroupSetBits call in the LIN_Runnable task to wake only the 2 tasks -
void createBlockEvent(void)
{
/* Attempt to create the event group. */
xEventGroup = xEventGroupCreate();
/* Was the event group created successfully? */
if( xEventGroup == NULL )
{
/* The event group was not created because there was insufficient
FreeRTOS heap available. */
}
else
{
/* The event group was created. */
xEventGroupSetBits(xEventGroup,LIN_TASK_WAKE);
}
}
at power on I set LIN_TASK_WAKE event & LIN Task set events for other 2 task.
when No lin communication below else part is called & go in sleep
but when LIN or other (total 6 )external interrupt occurs I need to call LIN_MainFunction() hence in post sleep config i need to set LIN_TASK_WAKE event