Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Bug report in p32 / macro.h
04-03-2014, 07:57 PM,
#1
Bug report in p32 / macro.h
Hi

I think I found a bug in
\x.4\p32\include\pinguino\core\macro.h

line 38
// Met le bit n à 0 dans octet
#define BitClear(byte, n) \
(byte = byte & !(1 << n))

the "!" is incorrect.
We should use "~" to make a binary not and not a logical not

// Met le bit n à 0 dans octet
#define BitClear(byte, n) \
(byte = byte & ~(1 << n))

As a result it might disable some IRQ it shouldn't (when called in IntDisable)
There is also probably a risk of loosing some IRQ because of calls made in IntClearFlag.

Can you confirm and patch the code in repository (I guess I don"t have rights to do it...)

Thanks
Reply
04-03-2014, 08:54 PM,
#2
RE: Bug report in p32 / macro.h
You look to be right and anyway this would be wiser:

#define BitClear(byte, n) ((byte) &= ~(1 << (n)))

I've added parens as well as using &=

John
Reply
04-03-2014, 11:30 PM,
#3
RE: Bug report in p32 / macro.h
Thank you guys.
I will fix it for both 8- and 32-bit.
It is easier to complain than it is to do, but it is better to do than it is to complain.
Reply
02-12-2014, 10:05 AM,
#4
RE: Bug report in p32 / macro.h
Correct. I did it for the Linux Makefile but forgot to fix it for the Windows one.
I will publish the new version soon.
Thanks.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)