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
lapa
PostPosted: Apr 11, 2012 - 01:59 PM
Wannabe


Joined: Jun 10, 2006
Posts: 90
Location: Madrid,Spain // Warsaw,Poland

Hi there folks!
I'm trying to figure out why pull-ups on PORTD/PORTB work just fine, and PORTC stay always low.. any suggestion?

Thats the code(as you can imagine:>) :

Code:

   DDRD = 0x00;
   PORTD = 0xFF;

   DDRB = 0x00;
   PORTB = 0xFF;

   DDRC = 0x00;
   PORTC = 0xFF;


Am I doing some stupid mistake? ADC is turned off. Any help will be appreciated..

Cheers!
Tom

_________________
-----
www.lapa.idl.pl
 
 View user's profile Send private message Visit poster's website 
Reply with quote Back to top
MBedder
PostPosted: Apr 11, 2012 - 02:04 PM
Raving lunatic


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

Swap the DDRx = and PORTx = statements (PORTx first, DDRx next), or even better put'em this way:
Code:

PORTB = 0xFF;
PORTC = 0xFF;
PORTD = 0xFF;

DDRB = 0;
DDRC = 0;
DDRD = 0;


Last edited by MBedder on Apr 11, 2012 - 02:10 PM; edited 1 time in total
 
 View user's profile Send private message  
Reply with quote Back to top
Jepael
PostPosted: Apr 11, 2012 - 02:08 PM
Raving lunatic


Joined: May 24, 2004
Posts: 5994
Location: Tampere, Finland

PORTC might work if you connected power supply to AVCC.
 
 View user's profile Send private message  
Reply with quote Back to top
MBedder
PostPosted: Apr 11, 2012 - 02:10 PM
Raving lunatic


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

Bingo!

_________________
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
lapa
PostPosted: Apr 11, 2012 - 02:20 PM
Wannabe


Joined: Jun 10, 2006
Posts: 90
Location: Madrid,Spain // Warsaw,Poland

Thanks for fast reply!
Actually Port C works - when DDRC is set as output, pins are driven. The problem is that pull-ups wont work.
Maybe I should add, the in AVR Studio 4 I compile the project for ATMega8, without 'A'

So far, changing order didn't help :/.
Tom

_________________
-----
www.lapa.idl.pl
 
 View user's profile Send private message Visit poster's website 
Reply with quote Back to top
MBedder
PostPosted: Apr 11, 2012 - 02:32 PM
Raving lunatic


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

Do you see this on real chip or on the simulator?

_________________
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
lapa
PostPosted: Apr 11, 2012 - 02:41 PM
Wannabe


Joined: Jun 10, 2006
Posts: 90
Location: Madrid,Spain // Warsaw,Poland

I see this on oscilloscope. Now I've noticed that only some pins don't do up (those that have other alternative functions then ADC). I don't difficult access to all of the pins, but SDA/SCL pins go up, and ADC0/1/2/3 don't... any idea?

_________________
-----
www.lapa.idl.pl
 
 View user's profile Send private message Visit poster's website 
Reply with quote Back to top
MBedder
PostPosted: Apr 11, 2012 - 02:51 PM
Raving lunatic


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

Make sure your AVCC pin is connected to VCC voltage as Jepael has suggested above.

_________________
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
lapa
PostPosted: Apr 18, 2012 - 01:10 PM
Wannabe


Joined: Jun 10, 2006
Posts: 90
Location: Madrid,Spain // Warsaw,Poland

Well ... as I could imagine. The problem was faulty ATMega8A - i must have short circuited some pins which destroyed the drivers ;/ (i guess). It works normally now ..

Anyway, thanks!
Tom

_________________
-----
www.lapa.idl.pl
 
 View user's profile Send private message Visit poster's website 
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