koor1200 wrote on Tuesday, February 23, 2016:
Hi
Thank you for thr response.
I changed heap_3 to heap_1 and it seems to have done the trick.
However no my code is generating a trap.
As I said I’m kind of new to freertos and I’m certain there are lots of mistake in the code.
My code is trying to creat 4 tasks :
void task_one(task_param_t param);
void task_two(task_param_t param);
void vATask(task_param_t param);
void vADifferentTask(task_param_t param);
task_one and task_two are periodic:
void task_one(task_param_t param)
{
int i = 0;
PRINTF(“This is Task One\n\n\r”);
PRINTF(“Press SW2 to Toggle Blue LED…\n\n\r”);
while(1)
{
vTaskDelay( 500 );
// Poll (sw2) if GPIO_INTERRUPT is not set
if(/*GPIO_DRV_ReadPinInput(kGpioSW2) == 0*/1)
{
//OSA_TimeDelay(200);
GPIO_DRV_TogglePinOutput(BOARD_GPIO_LED_GREEN);
}
PRINTF("%x\r\n",*test_rx_ptr);
}
}
void task_two(task_param_t param)
{
//int i = 0;
PRINTF(“This is Task Two\n\n\r”);
PRINTF(“Press SW2 to Toggle Blue LED…\n\n\r”);
while(1)
{
vTaskDelay( 700 );
// Poll (sw2) if GPIO_INTERRUPT is not set
if(GPIO_DRV_ReadPinInput(kGpioSW2) == 0)
{
//OSA_TimeDelay(200);
GPIO_DRV_TogglePinOutput(BOARD_GPIO_LED_GREEN);
}
test_var++;
}
}
vATask is a task that creates a queue and post a value to it
void vATask( void *pvParameters )
{
struct AMessage *pxMessage;
uint32_t * test_ptr;
// Create a queue capable of containing 10 pointers to AMessage structures.
// These should be passed by pointer as they contain a lot of data.
xQueue = xQueueCreate( 16, sizeof( unsigned int ) );
if( xQueue == 0 )
{
// Failed to create the queue.
}
// ...
// Send a pointer to a struct AMessage object. Don't block if the
// queue is already full.
pxMessage = & xMessage;
test_ptr= &test_var;
xQueueSend( xQueue, ( void * )/* &pxMessage*/&test_ptr, ( TickType_t ) 0 );
// ... Rest of task code.
}
vADifferentTask is a task that read the queue:
void vADifferentTask( void *pvParameters )
{
struct AMessage *pxRxedMessage;
//uint32_t test_rx_ptr;
if( xQueue != 0 )
{
// Receive a message on the created queue. Block for 10 ticks if a
// message is not immediately available.
if( xQueueReceive( xQueue,/* &( pxRxedMessage )*/&test_rx_ptr, ( TickType_t ) 10 ) )
{
// pcRxedMessage now points to the struct AMessage variable posted
// by vATask.
}
}
and here are the tasks creation
OSA_TaskCreate(task_two,“task_two”,TASK_ONE_STACK_SIZE,NULL,6u,NULL,false,&task_two_task_handler);
OSA_TaskCreate(vATask,“vATask”,TASK_ONE_STACK_SIZE,NULL,5u,NULL,false,&vATask_task_handler);
OSA_TaskCreate(vADifferentTask,“vADifferentTask”,TASK_ONE_STACK_SIZE,NULL,5u,NULL,false,&vADifferentTask_task_handler);
//create task
OSA_TaskCreate(task_one,
(uint8_t *)"task_one",
TASK_ONE_STACK_SIZE,
NULL,
TASK_ONE_PRIO,
(task_param_t)0,
false,
&task_one_task_handler);
what happens is it goes through thevATask and as soon as it returns it hits an eception which I believe is the HARD FAULT eception as my targer is an ARM CORTEX M4.
Sorry about the long post , but I need help.In the mean time I try to figure what I’m doing wrong.
Thanks,
Koorosh Hajiani