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] [January 2013 Threads] GPIO polling in freeRTOSPosted by ajinkya on January 31, 2013 I have very simple program written for polling a GPIO pin.
void main( void ) { #ifdef DEBUG debug(); #endif prvSetupHardware(); xTaskCreate( vOnOffPoll, "AC_ON_OFF_Poll", configMINIMAL_STACK_SIZE * 3, NULL, mainCHECK_TASK_PRIORITY - 1, NULL);
vTaskStartScheduler(); for( ;; ); }
First I tried simple if else loop inside while(1)
void vOnOffPoll(void *pvParameters) { while(1) { if( GPIO_ReadBit(GPIO4,GPIO_Pin_7) == Bit_RESET) GPIO_WriteBit(GPIO4, GPIO_Pin_0, Bit_SET); else GPIO_WriteBit(GPIO4, GPIO_Pin_0, Bit_RESET); }
then I tried switch case statement to do the same task in while(1)
void vOnOffPoll(void *pvParameters) { while(1) { int state=0; state = GPIO_ReadBit(GPIO4,GPIO_Pin_7); switch(state) { case 1: GPIO_WriteBit(GPIO4, GPIO_Pin_0, Bit_SET); break; case 0: GPIO_WriteBit(GPIO4, GPIO_Pin_0, Bit_RESET); break; } } }
I have no other task but still it gets executed once it dose not poll continuously.
Initially pin (GPIO4,GPIO_Pin_7) is connected to on board GND then (GPIO4,GPIO_Pin_0) is set but when I connect (GPIO4,GPIO_Pin_7) to on board VCC it is not changing state ((GPIO4,GPIO_Pin_0) is not reset) untill I reset kit keeping (GPIO4,GPIO_Pin_7) to on board VCC.
What is the problem? A task cannot be more simpler than this and still it is not working.
RE: GPIO polling in freeRTOSPosted by Dave on January 31, 2013 There is nothing wrong with the code you have written and because there is only one task that never blocks and the task runs with a priority that is higher than the idle priority the task should just run continuously. If you put a break point on the first line of the task then step through the code you should see what it is doing. You can also replace the while loop with a simple increment variable like volatile int i = 0;
while( 1 ) { i++; i++; }
run your code and check that the value of i is counted up. If it is then the task is being executed as expected. If the task does not execute as expected with the original GPIO code then it must be something in the GPIO functions that stops it.
RE: GPIO polling in freeRTOSPosted by ajinkya on January 31, 2013 Thanks davedoors for reply, Actually I was doing small mistake in pin configuration. Whole project we divided in modules and couldn't notice hardware config than should have changed at first place.
Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.
|