Experimenting with blinking LEDs, I learned about creating delays with either a software loop or a timeout from a timer. I know that for a simple blinking LED program, where the processes aren't that complicated and timing isn't crucial, using either wouldn't matter. But in more of a time-crucial multitasking context what are the benefits and/or disadvantages of both?
Thanks heaps, here's how I set them up:
Software delay:
void softwaredelay()
{
int i;
for(i=0; i<1000; i++)
{/*Timer Stuff*/}
}
Hardware delay (specific for PIC16 mcu's):
void timerdelay()
{
OPTION_REGbits.PSA = 0;
OPTION_REGbits.PS. = 0b111;
OPTION_REGbits.T0CS = 0;
INTCONbits.T0IF = 0;
TMR0 = 0b11111000;
INTCONbits.T0IE = 1;
while(INTCONbits.T0IF==0)
{/*Timer Stuff*/}
}