funkystuff wrote on Wednesday, December 02, 2015:
okey…Well…
uController -> Atmel sam3x8e
compiler -> ARM/GNU C compiler
freeRTOS version -> 7.3.0
SDK -> Atmel studio 7.0 with ASF
My application it’s composed by a simple task(sender) that create som messages and send theme to a specifica Queue and than it delete itself. To the other side there’s a task(motor_manager) that recive the messages from the queue and do some stuff. There’s the code:
Task sender:
void sender(void* pvParameters)
{
uint8_t rxValue;
motor_cmd cmd2 = {10,CCW,1,START};
motor_cmd cmd3 = {10,CCW,2,START};
motor_cmd cmd4 = {10,CCW,3,START};
motor_cmd cmd1 = {10,CCW,0,START};
uint8_t carattere = 33;
vTaskDelay(1000/portTICK_RATE_MS);
xQueueSend(tx_queue,&carattere,0);
xQueueSend(incoming_message,&cmd1,0);
xQueueSend(incoming_message,&cmd2,0);
xQueueSend(incoming_message,&cmd3,0);
xQueueSend(incoming_message,&cmd4,0);
while(1);
}
Task motor_manager:
void motor_manager(void* pvParameters)
{
portBASE_TYPE xStatus;
motor_cmd in_msg;
for (int i = 0;i < 8;i++)
{
if(pwm_ch_enable[i] == 1)
{
pwm_ch_enabled[i] = i;
nMotors[i].status = IDLE;
nMotors[i].isEnabled = true;
nMotors[i].cmd_steps = 0;
nMotors[i].remaning_steps = 0;
pio_configure_pin(CH0_PIN + i,PIO_TYPE_PIO_OUTPUT_0);
pio_set_pin_low(CH0_PIN + i);
xStatus = xTaskCreate(motor_channel_manager,“Gestore_canale”,configMINIMAL_STACK_SIZE,&pwm_ch_enabled[i],CHANNEL_TASK_PRIORITY,NULL);
if(xStatus != pdPASS)
{
A9488_drv_fault = true;
vTaskDelete(NULL);
}
}
}
vTaskPrioritySet(NULL,(configMAX_PRIORITIES - 3));
while(1)
{
if (uxQueueMessagesWaiting(incoming_message) > 0)
{
xQueueReceive(incoming_message,&in_msg,portMAX_DELAY);
if(nMotors[in_msg.ch].isEnabled && nMotors[in_msg.ch].status == IDLE)
{
nMotors[in_msg.ch].cmd_steps = in_msg.n_steps*2;
nMotors[in_msg.ch].remaning_steps = nMotors[in_msg.ch].cmd_steps;
nMotors[in_msg.ch].rot = in_msg.direction;
nMotors[in_msg.ch].status = RUNNING;
}
}
taskYIELD();
}
}
the main:
int main (void)
{
sysclk_init();
board_init();
irq_initialize_vectors();
cpu_irq_enable();
xTaskCreate(init_system_task,"Boot_task",configMINIMAL_STACK_SIZE,NULL,(configMAX_PRIORITIES - 2),NULL);
xTaskCreate(sender,"sender_task",configMINIMAL_STACK_SIZE,NULL,TX_PRIORITY,NULL);
vTaskStartScheduler();
while(1);
}
the code seems work great…but after 10s it crash and reboot…i tryed to disable the WDT but nothing happends!!!..the only things i’ve changed in freeRTOSConfig.h is:
configUSE_MALLOC_FAILED_HOOK (1 -> 0)
because the compiler give me some errors.
thanks
Tommaso.