biradarajinkya wrote on Thursday, 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.