Hi team please refer to the below code, I was just trying to measure the software delays by toggling the gpio pin using scope.
I have used HALCOGEN to generate code for GIO driver.
void main(void)
{
gioInit(); //initalize gio driver
gioSetDirection(gioPORTA, 0x000000FE);
gioSetBit(gioPORTA, 1, 1);
#if 0 //dummy code
gioSetBit(gioPORTA, 2, 1);
if(gioGetBit(gioPORTA,2))
{
printf("bit is set");
}
else
{
printf("bit is not set");
}
gioSetBit(gioPORTA, 5, 0);
if(gioGetBit(gioPORTA,5))
{
printf("bit is set");
}
else
{
printf("bit is not set");
}
#endif
while(1)
{
gioSetBit(gioPORTA, 1, 0); // set pin 1 as low
delay(925); // delay
gioSetBit(gioPORTA, 1, 1); // set pin 1 as high
delay(10000); //delay
}
}
void delay(long value)
{
long i;
for(i=0;i<value;i++);
}
if I'm not including the dummy code ( #if 0 ) and measure the delay for the off time using the scope, I got 104 microseconds but once when I try to include this dummy code (by making #if 1) the delay i could measure for the off time is just 87 microseconds which is reduced. And if I add some more codes the delay is further getting reduced (without changing the delay value 925). I expect that the delay should not be changing even if i add some more tasks but eventually its not happening its keep on changing something I don't understand so could some one please suggest or help me regarding this.
Thanks in advance,
Regards,
Bala