FreeRTOS Support Archive
The FreeRTOS support forum is used to obtain active support directly from Real
Time Engineers Ltd. In return for using our top quality software and services for
free, we request you play fair and do your bit to help others too! Sign up
to receive notifications of new support topics then help where you can.
This is a read only archive of threads posted to the FreeRTOS support forum.
The archive is updated every week, so will not always contain the very latest posts.
Use these archive pages to search previous posts. Use the Live FreeRTOS Forum
link to reply to a post, or start a new support thread.
[FreeRTOS Home] [Live FreeRTOS Forum] [FAQ] [Archive Top] [July 2011 Threads] PIC32 PORTSetBits macroPosted by Kristof Eykens on July 22, 2011 When using these peripheral macro's when initializing the board the instruction are executed. When I use theses macro's like PORTSetBits and PORTClearBits within a vTaskSupendAll code block. The motor are not started or stopped. Am I missing some configuration?
RE: PIC32 PORTSetBits macroPosted by Kristof Eykens on July 22, 2011 prototype of the task looks like this:
void vTaskCPanel(void *pvParameters) { char action; portBASE_TYPE xStatus; char isBusy = 0; TaskType event; unsigned int sensorValue;
datacontainer data; pin_locationmotor; pin_locationsensor;
motor.portId1 = IOPORT_F; motor.bit1= BIT_0; motor.portId2= IOPORT_F; motor.bit2= BIT_1;
sensor.portId1 = IOPORT_B; sensor.bit1= BIT_15; sensor.portId2= IOPORT_D; sensor.bit2= BIT_4;
data.motor = motor; data.sensor = sensor;
for(;;) { // wait for action queue, to be filled by vTaskEthListener if (isBusy == 0) { xStatus = xQueueReceive(xQueueCPanel, &action, portMAX_DELAY); if ( xStatus == pdPASS) { isBusy = 1; event = Start; } else { // TODO: send error } }
// handle action switch (action) { case 0: switch (event) { case Start: vTaskSuspendAll(); { PORTSetBits(IOPORT_F, BIT_0); PORTClearBits(IOPORT_F, BIT_1); } xTaskResumeAll();
event = Running; break; case Running: vTaskSuspendAll(); { sensorValue = PORTReadBits(IOPORT_B, BIT_15); if (sensorValue == 0) { InternalMotorStop(&motor); event = Stopped; } } xTaskResumeAll();
break; case Stopped: isBusy = 0; break; } // TODO: read core timer to check for sensor errors
// Delay task vTaskDelay(100/portTICK_RATE_MS); break; case 1: switch (event) { case Start: vTaskSuspendAll(); { PORTSetBits(motor.portId2, motor.bit2); PORTClearBits(motor.portId1, motor.bit1); } xTaskResumeAll();
event = Running; break; case Running: vTaskSuspendAll(); { sensorValue = PORTReadBits(sensor.portId2, sensor.bit2); if (sensorValue == 0) { InternalMotorStop(&motor); event = Stopped; } } xTaskResumeAll();
break; case Stopped: isBusy = 0; break; } // TODO: read core timer to check for sensor errors
// Delay task vTaskDelay(100/portTICK_RATE_MS); break; } } }
RE: PIC32 PORTSetBits macroPosted by Kristof Eykens on July 25, 2011 After rewriting the project with FreeRTOS, I forgot to enable the motor circuit... Sorry for my stupidity!
Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.
|