Hello All,
I am working on a FreeRTOS project on mcuxpresso , ksdk 2.5 and cortex m4 and at the moment, I simply want to get a task to blink an LED. The project runned without problems when the task function was defined in the main.c file. For clarity, I moved the LED task into its its own “User
taskfunction.c” and included the “User
taskfunction.h” in the main. Afterwards, the program will raise a hardware fault in the LED task when it calls DelayUntil(). I have tried for several days. I will appreciate help in resolving this issue. I have attached the project.
`
#ifdef __cplusplus
extern “C” {
#endif
#include "MK22F51212.h"
#include "fsl_clock.h"
#include "clock_config.h"
#include "Defs.h"
#include "FreeRTOS.h"
#include "task.h"
#include "semphr.h"
#include "timers.h"
#include "queue.h"
#include "fsl_port.h"
#include "fsl_gpio.h"
#include "global_variable.h"
#include "user_task_functions.h"
#include "pins.h"
#include "pin_mux.h"
#ifdef cplusplus
}
#endif
int main ()
{
BOARD
BootClockHSRUN();
BOARDInitBootPins();
if (xTaskCreate(air_blinky, "air_blinky_A", 200, &Board_A_blinky, blinkyPriority,
&BlinkyAhandle) == errCOULD_NOT_ALLOCATE_REQUIRED_MEMORY)
exit(-1);
vTaskStartScheduler();
while(true);
return 0;
}
`
// Below is the Header for the task function.
#ifndef USER_TASK_FUNCTIONS_H_
#define USER
TASKFUNCTIONS
H
#include “Defs.h”
#include “FreeRTOS.h”
#include “task.h”
#include “global
variable.h”
#include “fslgpio.h”`
void air
blinky(void* blinkyparameters);
void vApplicationIdleHook( void );
`#endif /* USER
TASKFUNCTIONS
H */“
// Below is the task functions definition
`#include “user
taskfunctions.h”
void air
blinky(void* blinkyparameters)
{
volatile BLINKY_param_t* LED = (BLINKY_param_t*) blinky_parameters;
char* Mytaskname = pcTaskGetName(NULL);
TickType_t xBlinkyLastwakeuptime = xTaskGetTickCount();
const TickType_t Flash_Time = 100;
const TickType_t Flash_Return_Time = 2000;
GPIO_PortClear(LED->GPIO, mask(LED->Pin_name)); // on
for (;;)
{
if( isTasksuspended & (!(strcmp(Mytaskname,"air_blinky_A")) ? 0b10000000 : 0b00010000) ) // area to publish a paper on
{
portTICK_TYPE_ENTER_CRITICAL();
xBlinkyLastwakeuptime = xTaskGetTickCount();
isTasksuspended &= ( (!(strcmp(Mytaskname,"air_blinky_A"))) ? 0b01111111 : 0b11101111 ) ;
portTICK_TYPE_EXIT_CRITICAL();
}
{
GPIO_PortClear (LED->GPIO, mask(LED->Pin_name));
GPIO_PortToggle (LED->GPIO, mask(LED->Pin_name));
vTaskDelayUntil (&xBlinkyLastwakeuptime,Flash_Time);
GPIO_PortToggle (LED->GPIO, mask(LED->Pin_name));
vTaskDelayUntil (&xBlinkyLastwakeuptime,Flash_Time);
GPIO_PortToggle (LED->GPIO, mask(LED->Pin_name));
vTaskDelayUntil (&xBlinkyLastwakeuptime,Flash_Time);
GPIO_PortToggle (LED->GPIO, mask(LED->Pin_name));
vTaskDelayUntil (&xBlinkyLastwakeuptime, Flash_Return_Time);
}
}
`
`
// Below is the header for the global variables
~~~
ifndef GLOBALVARIABLEH_
define GLOBALVARIABLEH_
include “stdint.h”
include “stddef.h”
include “FreeRTOS.h”
include “task.h”
include “semphr.h”
include “Defs.h”
include “pins.h”
include “arm_math.h”
~~~
extern uint8
t isTasksuspended ;
extern BLINKYparam
t BoardA
blinky ;
extern BLINKYparam
t BoardB
blinky ;
extern TaskHandlet BlinkyAhandle ;
extern TaskHandle
t BlinkyBhandle ;
extern TaskHandlet MasterTaskhandle ;
extern SemaphoreHandle
t INTERRUPTsemphr ;
extern bool ActuatorOneDetectState ;
extern bool ActuatorTwoDetectState ;
extern arm
biquadcasd
df1inst
f32 NoiseFilter ;
extern float32t corrupt
dataA[Blocksize];
extern float32t corrupt
dataB[Blocksize];
extern float32t outputA[Blocksize] ;
extern float32_t outputB[Blocksize] ;
#endif /* GLOBAL_VARIABLE_H_ */
`
// Below is my global variables
`#include “global_variable.h”
uint8_t isTasksuspended = 0;
BLINKY_param_t Board_A_blinky = { GPIOE, PTE1 } ;
BLINKY_param_t Board_B_blinky = { GPIOB, PTB22} ;
TaskHandle_t BlinkyAhandle = NULL ;
TaskHandle_t BlinkyBhandle = NULL ;
TaskHandle_t MasterTaskhandle = NULL ;
SemaphoreHandle_t INTERRUPT_semphr = NULL ;
bool ActuatorOneDetectState = false ;
bool ActuatorTwoDetectState = false ;
arm_biquad_casd_df1_inst_f32 NoiseFilter ;
float32_t corrupt_dataA[Blocksize] = {0} ;
float32_t corrupt_dataB[Blocksize] = {0} ;
float32_t outputA[Blocksize] = {0} ;
float32_t outputB[Blocksize] = {0} ;
`