sonar_abhi
Member level 1
Hello all,
Can anybody please explain to me how does this particular code work in mikroc. The timer is set to overflow every 32ms. Thus, the following code toggles the PortB pins roughly every 1 second.
Initinterrupt ()
{
======;
======;
}
Interrupt()
{
========;
========;
timerint++;
}
Void main ()
{
Initinterrupt();
TRISB =0;
PORTB =0;
while (1)
{
if (timerint==32)
{
PORTB=~PORTB;
timerint=0;
}
}
So far so good,
But if I set the PortB value after while loop, the timer function does not work as expected.
Can someone explain me why so. The above code is just an abstraction of an another function that I am using which isn't working as expected. Will post that function also tomorrow.
Regards,
Abhishek
Can anybody please explain to me how does this particular code work in mikroc. The timer is set to overflow every 32ms. Thus, the following code toggles the PortB pins roughly every 1 second.
Initinterrupt ()
{
======;
======;
}
Interrupt()
{
========;
========;
timerint++;
}
Void main ()
{
Initinterrupt();
TRISB =0;
PORTB =0;
while (1)
{
if (timerint==32)
{
PORTB=~PORTB;
timerint=0;
}
}
So far so good,
But if I set the PortB value after while loop, the timer function does not work as expected.
Can someone explain me why so. The above code is just an abstraction of an another function that I am using which isn't working as expected. Will post that function also tomorrow.
Regards,
Abhishek