Skip to main content
edited tags
Link
Roh
  • 4.7k
  • 7
  • 46
  • 86
Source Link

How to handle polling method in micro controllers.?

I am using PIC32MX795F512L Micro Controller.

I need to develop an application where 4 led's connected to pins of controller will blink continuously at a rate of 1sec and there are 15 inputs connected to controller. These inputs will send some data to UART whenever they get HIGH. For example:

while(1)
{
if(input1 == HIGH)
{
 putsUART1("input1 HIGH"); 
}
if(input2 == HIGH)
{
 putsUART1("input2 HIGH");
}

//same for rest of the inputs

LED1 = HIGH
delay(1000);
LED2 = HIGH
delay(1000);
LED3 = HIGH
delay(1000);
LED4 = HIGH
delay(1000);

LED1 = LOW
delay(1000);
LED2 = LOW
delay(1000);
LED2 = LOW
delay(1000);
LED2 =LOW
delay(1000);
}

above technique is polling method and is not giving real time input data to UART. I thought of using UART TX Interrupt but dont have good experience in it. I have just downloaded FreeRTOS for PIC32 and created few task and using RTOS it is working fine. Should I continue using RTOS or switch to use Interrupts. If there is any other way of doing it, Please help