Page 1 of 1

AVR BUG!

Posted: Sat Dec 07, 2013 2:25 pm
by nnnnff
AVR 5.5,“NOT”No effect.Can the Flowcode simulation.Burn wrote chip is no reaction.Inside the proteus also no response!Help me.Thank you very much!
AVR bug.rar
(38.8 KiB) Downloaded 313 times

Re: AVR BUG!

Posted: Sat Dec 07, 2013 2:38 pm
by medelec35
Hi nnnnff,
Have you tried

Code: Select all

b = !b
?

Martin

Re: AVR BUG!

Posted: Sun Dec 08, 2013 12:36 am
by nnnnff
caculation:why "!"do!"NOT"not?

Re: AVR BUG!

Posted: Sun Dec 08, 2013 12:49 am
by medelec35
On PIC ! always works for me,

Did it work for you?

Have you checked on hardware, or just simulation?

Re: AVR BUG!

Posted: Wed Dec 11, 2013 12:10 am
by Benj
Hello,

The C code being produced is this.

Code: Select all

            //Calculation:
            //  b = NOT b
            FCV_B = ~FCV_B;
~ and ! are slightly different in their operations though your program looks to me like it should work. Hmm.

From stack overflow.
For integral types, ! returns true if the operand is zero, and false otherwise.
So !b here just means b == 0.
As far as I know ~ should flip all the bits in the value so 0x00 would become 0xFF which should work. I may however be wrong on this if its not working on the hardware.