Forum Menu




 


Log in Problems?
New User? Sign Up!
AVR Freaks Forum Index

Post new topic   Reply to topic
View previous topic Printable version Log in to check your private messages View next topic
Author Message
transporter08
PostPosted: May 15, 2012 - 12:58 PM
Newbie


Joined: Oct 09, 2009
Posts: 3


Hi all,

i have a strange problem with an ATmega32U2.

i have 3 pins on PORTB (PB5, PB6, PB7) as input the others are outputs (via DDRB = 0x1F).
At PB7 the internal pullup is enabled (PORTB =
0x80).

PB7 is not connected.
PB6 is connected to VCC with an external 4k7 pullup.
PB5 is connected with Y-Output (Pin5) from a HC151 (all MUX-Inputs of the HC151 are at VCC level)

In the main loop i print out the content of PINB register via UART.

If i power on the circuit then it gives me 0xE0 as PINB content (it means PB7,PB6,PB5 = 1) (like expected).

After 1-2 seconds it changes to 0x80 (it means PB6,PB5 = 0), but nothing was touched.

If i measure the level at PB5 and PB6 with a voltage meter, i see +5V for both ?!?!?!

if i tie PB6 (this one with the external pullup) to GND, the display keeps showing 0x80, if i remove the GND cable i see 0xC0 for a short time (it means PB7,PB6 = 1, PB5 = 0).

After this i see 0x80 again.

From where comes the internal AVR 0-level at PB6,PB5, even if i measure +5V with the meter ?

Thank you in advance.

Code:

int main(void)
{
UARTInit();

DDRB = 0x1F;
PORTB = 0x80;

for (;Wink
{
UARTPrintNL ();
UARTPrintHex( PINB );
}
}
 
 View user's profile Send private message  
Reply with quote Back to top
MBedder
PostPosted: May 15, 2012 - 01:33 PM
Raving lunatic


Joined: Nov 02, 2009
Posts: 3239
Location: Zelenograd, Russia


_________________
Warning: Grumpy Old Chuff. Reading this post may severely damage your mental health.
 
 View user's profile Send private message  
Reply with quote Back to top
transporter08
PostPosted: May 15, 2012 - 01:39 PM
Newbie


Joined: Oct 09, 2009
Posts: 3


Code:

int main(void)
{
  UARTInit();

  DDRB  = 0x1F;
  PORTB = 0x80;

  for (;;)
  {
    uint8_t pinvalue = PINB;

    UARTPrintNL ();
    UARTPrintHex( pinvalue );
  }
}
 
 View user's profile Send private message  
Reply with quote Back to top
MBedder
PostPosted: May 15, 2012 - 01:42 PM
Raving lunatic


Joined: Nov 02, 2009
Posts: 3239
Location: Zelenograd, Russia

"My car is not working. Please help!"

_________________
Warning: Grumpy Old Chuff. Reading this post may severely damage your mental health.
 
 View user's profile Send private message  
Reply with quote Back to top
transporter08
PostPosted: May 15, 2012 - 01:50 PM
Newbie


Joined: Oct 09, 2009
Posts: 3


@MBedder:

the code is working. i only posted it again with code formatting.
Please read the first post. The problem is an AVR internal Low-Level read out from register PINB even if the voltage meter at these pins says: +5V.

Do you have some ideas on this ?

Thank you in advance.
 
 View user's profile Send private message  
Reply with quote Back to top
MBedder
PostPosted: May 15, 2012 - 02:25 PM
Raving lunatic


Joined: Nov 02, 2009
Posts: 3239
Location: Zelenograd, Russia

transporter08 wrote:
the code is working... The problem is an AVR internal Low-Level read out from register PINB even if the voltage meter at these pins says: +5V.
"My friend is alive. The problem is that he's dead". Laughing

To get help you have to post the entire code.
 
 View user's profile Send private message  
Reply with quote Back to top
Chuck-Rowst
PostPosted: May 15, 2012 - 04:07 PM
Hangaround


Joined: Jul 19, 2011
Posts: 460


transporter08,

Try disconnecting PB6 & PB5 from external circuits and configuring them with internal pull-ups (like PB7). Do you get the same result?

If not, reconnect externals one-by-one. Does oen of them cause the problem?
 
 View user's profile Send private message  
Reply with quote Back to top
Display posts from previous:     
Jump to:  
All times are GMT + 1 Hour
Post new topic   Reply to topic
View previous topic Printable version Log in to check your private messages View next topic
Powered by PNphpBB2 © 2003-2006 The PNphpBB Group
Credits