<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: FreeRTOS is not switching context between 2 tasks in S32 SDK</title>
    <link>https://community.nxp.com/t5/S32-SDK/FreeRTOS-is-not-switching-context-between-2-tasks/m-p/1445557#M2499</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;I tried your code on freertos_mpc5748g demo and it seems it is running on MPC5748G EVB. I just added PTG pins in pin_mux component.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="PetrS_0-1650355864104.png" style="width: 400px;"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/177265i3485B17D3EAA2FBC/image-size/medium?v=v2&amp;amp;px=400" role="button" title="PetrS_0-1650355864104.png" alt="PetrS_0-1650355864104.png" /&gt;&lt;/span&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="PetrS_1-1650355877098.png" style="width: 400px;"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/177266i6A7DBA432CDE00A2/image-size/medium?v=v2&amp;amp;px=400" role="button" title="PetrS_1-1650355877098.png" alt="PetrS_1-1650355877098.png" /&gt;&lt;/span&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="PetrS_2-1650355891018.png" style="width: 400px;"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/177267i97D04D9B33BDF64E/image-size/medium?v=v2&amp;amp;px=400" role="button" title="PetrS_2-1650355891018.png" alt="PetrS_2-1650355891018.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;BR, Petr&lt;/P&gt;</description>
    <pubDate>Tue, 19 Apr 2022 08:12:10 GMT</pubDate>
    <dc:creator>PetrS</dc:creator>
    <dc:date>2022-04-19T08:12:10Z</dc:date>
    <item>
      <title>FreeRTOS is not switching context between 2 tasks</title>
      <link>https://community.nxp.com/t5/S32-SDK/FreeRTOS-is-not-switching-context-between-2-tasks/m-p/1443536#M2494</link>
      <description>&lt;P&gt;Hi:&lt;/P&gt;&lt;P&gt;The setup is on MP5748G EVB.&amp;nbsp; I have setup 2 tasks with same priority using FreeRTOS in debug mode.&amp;nbsp; I have place 2 breakpoints in 2 different task entries.&amp;nbsp; Also, each task will blink different user LED on board.&lt;/P&gt;&lt;P&gt;After launched task scheduler, only Task1 is running.&amp;nbsp; Task2 will not get schedule, or only schedule once at beginning.&amp;nbsp; I don't see any context switching between 2 tasks being created.&amp;nbsp; Is there anything wrong????&lt;/P&gt;&lt;P&gt;The following is the code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="c"&gt;/*
 * Copyright (c) 2013 - 2015, Freescale Semiconductor, Inc.
 * Copyright 2016-2017 NXP
 * All rights reserved.
 *
 * THIS SOFTWARE IS PROVIDED BY NXP "AS IS" AND ANY EXPRESSED OR
 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
 * IN NO EVENT SHALL NXP OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
 * THE POSSIBILITY OF SUCH DAMAGE.
 */
/* ###################################################################
**     Filename    : main.c
**     Processor   : MPC574xG
**     Abstract    :
**         Main module.
**         This module contains user's application code.
**     Settings    :
**     Contents    :
**         No public methods
**
** ###################################################################*/
/*!
** @file main.c
** @version 01.00
** @brief
**         Main module.
**         This module contains user's application code.
*/         
/*!
**  @addtogroup main_module main module documentation
**  @{
*/         
/* MODULE main */


/* Including necessary module. Cpu.h contains other modules needed for compiling.*/
#include "Cpu.h"
#include "FreeRTOS.h"
#include "clockMan1.h"
#include "pin_mux.h"
#include "task.h"

  volatile int exit_code = 0;
/* User includes (#include below this line is not maintained by Processor Expert) */
#include "clockMan1.h"
//#include "pins_driver.h"

#define PIN_LOW			0
#define PIN_HIGH		1

#define	LED_DELAY_MS		((TickType_t)1000/portTICK_PERIOD_MS)
#define	TSK_BASE_PRIORITY	(tskIDLE_PRIORITY + 2)

volatile int testValue = 0;
void vSystemInit(void);
void vTestTask(void *pParam);
void vTestTask2(void *pParam);
void vTickDelay(uint32_t ulCycles);
/*! 
  \brief The main function for the project.
  \details The startup initialization sequence is the following:
 * - startup asm routine
 * - main()
*/
int main(void)
{
  /* Write your local variable definition here */

  /*** Processor Expert internal initialization. DON'T REMOVE THIS CODE!!! ***/
  #ifdef PEX_RTOS_INIT
    PEX_RTOS_INIT();                   /* Initialization of the selected RTOS. Macro is defined by the RTOS component. */
  #endif
  /*** End of Processor Expert internal initialization.                    ***/

  /* Write your code here */
  /* For example: for(;;) { } */
    vSystemInit();

    PINS_DRV_WritePin(PTG, 2, 1);
    PINS_DRV_WritePin(PTG, 3, 1);
    PINS_DRV_WritePin(PTG, 4, 1);
    PINS_DRV_WritePin(PTG, 5, 1);

    xTaskCreate(vTestTask, (const char * const)"TestTask", configMINIMAL_STACK_SIZE, (void *)0, TSK_BASE_PRIORITY, NULL);
    xTaskCreate(vTestTask2, (const char * const)"TestTask", configMINIMAL_STACK_SIZE, (void *)1, TSK_BASE_PRIORITY, NULL);
    //xTaskCreate(vTestTask, (const char * const)"TestTask3", configMINIMAL_STACK_SIZE, (void *)2, TSK_BASE_PRIORITY+2, NULL);
    //xTaskCreate(vTestTask, (const char * const)"TestTask4", configMINIMAL_STACK_SIZE, (void *)3, TSK_BASE_PRIORITY+3, NULL);

    vTaskStartScheduler();

  /*** Don't write any code pass this line, or it will be deleted during code generation. ***/
  /*** RTOS startup code. Macro PEX_RTOS_START is defined by the RTOS component. DON'T MODIFY THIS CODE!!! ***/
  #ifdef PEX_RTOS_START
    PEX_RTOS_START();                  /* Startup of the selected RTOS. Macro is defined by the RTOS component. */
  #endif
  /*** End of RTOS startup code.  ***/
  /*** Processor Expert end of main routine. DON'T MODIFY THIS CODE!!! ***/
  for(;;) {
    if(exit_code != 0) {
      break;
    }
  }
  return exit_code;
  /*** Processor Expert end of main routine. DON'T WRITE CODE BELOW!!! ***/
} /*** End of main routine. DO NOT MODIFY THIS TEXT!!! ***/

/* END main */
void vSystemInit()
{
	CLOCK_SYS_Init(g_clockManConfigsArr, CLOCK_MANAGER_CONFIG_CNT,
					g_clockManCallbacksArr, CLOCK_MANAGER_CALLBACK_CNT);
	CLOCK_SYS_UpdateConfiguration(0U, CLOCK_MANAGER_POLICY_FORCIBLE );

	PINS_DRV_Init(NUM_OF_CONFIGURED_PINS, g_pin_mux_InitConfigArr);
}

void vTestTask(void *pParam)
{
	uint32_t ulLED = (uint32_t)pParam;
	for(;;){
		//vTaskDelay(1000);
		//vTickDelay(1000000);
		PINS_DRV_WritePin(PTG, 2, 0);
		//testValue = (testValue + 1) % 100;
		//vTickDelay(1000000);
		PINS_DRV_WritePin(PTG, 2, 1);
		//vTaskDelay(LED_DELAY_MS);
		//vTaskDelay(LED_DELAY_MS);
	}
}

void vTestTask2(void *pParam)
{
	uint32_t ulLED = (uint32_t)pParam;
	for(;;){
		//vTaskDelay(1000);
		//vTickDelay(1000000);
		PINS_DRV_WritePin(PTG, 3, 0);
		//testValue = (testValue + 1) % 100;
		//vTickDelay(1000000);
		PINS_DRV_WritePin(PTG, 3, 1);
		//vTaskDelay(LED_DELAY_MS);
		//vTaskDelay(LED_DELAY_MS);
	}
}

void vTickDelay(uint32_t ulCycles)
{
	while(--ulCycles &amp;gt; 0);
}
/*!
** @}
*/
/*
** ###################################################################
**
**     This file was created by Processor Expert 10.1 [05.21]
**     for the NXP C55 series of microcontrollers.
**
** ###################################################################
*/&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;James&lt;/P&gt;</description>
      <pubDate>Wed, 13 Apr 2022 18:12:48 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S32-SDK/FreeRTOS-is-not-switching-context-between-2-tasks/m-p/1443536#M2494</guid>
      <dc:creator>karma_JC</dc:creator>
      <dc:date>2022-04-13T18:12:48Z</dc:date>
    </item>
    <item>
      <title>Re: FreeRTOS is not switching context between 2 tasks</title>
      <link>https://community.nxp.com/t5/S32-SDK/FreeRTOS-is-not-switching-context-between-2-tasks/m-p/1445557#M2499</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;I tried your code on freertos_mpc5748g demo and it seems it is running on MPC5748G EVB. I just added PTG pins in pin_mux component.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="PetrS_0-1650355864104.png" style="width: 400px;"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/177265i3485B17D3EAA2FBC/image-size/medium?v=v2&amp;amp;px=400" role="button" title="PetrS_0-1650355864104.png" alt="PetrS_0-1650355864104.png" /&gt;&lt;/span&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="PetrS_1-1650355877098.png" style="width: 400px;"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/177266i6A7DBA432CDE00A2/image-size/medium?v=v2&amp;amp;px=400" role="button" title="PetrS_1-1650355877098.png" alt="PetrS_1-1650355877098.png" /&gt;&lt;/span&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="PetrS_2-1650355891018.png" style="width: 400px;"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/177267i97D04D9B33BDF64E/image-size/medium?v=v2&amp;amp;px=400" role="button" title="PetrS_2-1650355891018.png" alt="PetrS_2-1650355891018.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;BR, Petr&lt;/P&gt;</description>
      <pubDate>Tue, 19 Apr 2022 08:12:10 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S32-SDK/FreeRTOS-is-not-switching-context-between-2-tasks/m-p/1445557#M2499</guid>
      <dc:creator>PetrS</dc:creator>
      <dc:date>2022-04-19T08:12:10Z</dc:date>
    </item>
    <item>
      <title>Re: FreeRTOS is not switching context between 2 tasks</title>
      <link>https://community.nxp.com/t5/S32-SDK/FreeRTOS-is-not-switching-context-between-2-tasks/m-p/1447433#M2507</link>
      <description>&lt;P&gt;Hi Petrs:&lt;/P&gt;&lt;P&gt;I tried again. But, it is not working for me.&amp;nbsp; I turned the FRZ to 0 as well.&amp;nbsp; Also, vTaskDelay is not returning as well.&amp;nbsp; Is there other settings need to take care???&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;James&lt;/P&gt;</description>
      <pubDate>Thu, 21 Apr 2022 18:20:33 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S32-SDK/FreeRTOS-is-not-switching-context-between-2-tasks/m-p/1447433#M2507</guid>
      <dc:creator>karma_JC</dc:creator>
      <dc:date>2022-04-21T18:20:33Z</dc:date>
    </item>
    <item>
      <title>Re: FreeRTOS is not switching context between 2 tasks</title>
      <link>https://community.nxp.com/t5/S32-SDK/FreeRTOS-is-not-switching-context-between-2-tasks/m-p/1449718#M2513</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;I just tried your code in demo example, see attached.&lt;/P&gt;
&lt;P&gt;BR, Petr&lt;/P&gt;</description>
      <pubDate>Wed, 27 Apr 2022 07:27:19 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S32-SDK/FreeRTOS-is-not-switching-context-between-2-tasks/m-p/1449718#M2513</guid>
      <dc:creator>PetrS</dc:creator>
      <dc:date>2022-04-27T07:27:19Z</dc:date>
    </item>
    <item>
      <title>Re: FreeRTOS is not switching context between 2 tasks</title>
      <link>https://community.nxp.com/t5/S32-SDK/FreeRTOS-is-not-switching-context-between-2-tasks/m-p/1449975#M2514</link>
      <description>&lt;P&gt;Hi PetrS:&lt;/P&gt;&lt;P&gt;I got the task switching work couple days ago on FreeRTOS.&amp;nbsp; The only thing being changed is FRZ bit which related to VTaskDelay.&amp;nbsp; I'm not sure this being right solution for this issue.&amp;nbsp; When I turned off FRZ bit in configuration, everything work fine.&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;James&lt;/P&gt;</description>
      <pubDate>Wed, 27 Apr 2022 15:03:38 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S32-SDK/FreeRTOS-is-not-switching-context-between-2-tasks/m-p/1449975#M2514</guid>
      <dc:creator>karma_JC</dc:creator>
      <dc:date>2022-04-27T15:03:38Z</dc:date>
    </item>
  </channel>
</rss>

