How can 256 be greater than 500?
i have variable i'm incrementing in interrupt function. variable declared volatile int.
in loop() check value of incremented variable. when passes threshold, take further action.
in essence, i'm doing this:
void interruptfunction()
{
samplecount++;
}
void loop()
{
if (samplecount > 500)
{
serial.println(samplecount);
samplecount = 0;
}
}
most of time, samplecount 500 or 501. maybe 1 in 20 30 times, samplecount 256!
the clue have incorrect value of samplecount greatest multiple of 256 less test amount. is:
test 500 samplecount may 256
test 520 samplecount may 512
test 1000 samplecount may 768
it may worth noting interrupt being called using timerone library.
any explanation mystery?
thanks lot help,
john
in loop() check value of incremented variable. when passes threshold, take further action.
in essence, i'm doing this:
void interruptfunction()
{
samplecount++;
}
void loop()
{
if (samplecount > 500)
{
serial.println(samplecount);
samplecount = 0;
}
}
most of time, samplecount 500 or 501. maybe 1 in 20 30 times, samplecount 256!
the clue have incorrect value of samplecount greatest multiple of 256 less test amount. is:
test 500 samplecount may 256
test 520 samplecount may 512
test 1000 samplecount may 768
it may worth noting interrupt being called using timerone library.
any explanation mystery?
thanks lot help,
john
http://arduino.cc/en/reference/volatile
maybe
maybe
Arduino Forum > Forum 2005-2010 (read only) > Software > Syntax & Programs > How can 256 be greater than 500?
arduino
Comments
Post a Comment