I'm trying to read an active low sensor on port B, pin 6 of an ATMega2561. Pins 5 and 7 are set to output, and 0 and 1, respectively. So I figured I should just sit in a loop waiting for PINB & 0xC0 to go from 1 to 0. You can see (hopefully) in the attached composited screen grab, however, that, when AVR Studio breaks right after the loop, PINB is still == 0xC0. So, I assume PINB & 0xC0 == 1 and the loop shouldn't have broken. The sensor goes active for about .5 second every 5 seconds, and its signal is very clean, so I don't think this is a noise or glitch issue. Probably a newbie programming one. Any thoughts? Thanks.
Joined: Tue. Apr 1, 2003
Posts: 480 View posts