| Author |
Message |
|
|
Posted: Apr 11, 2012 - 01:59 PM |
|

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
|
| |
|
|
|
|
|
Posted: Apr 11, 2012 - 02:04 PM |
|

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
|
| |
|
|
|
|
|
Posted: Apr 11, 2012 - 02:08 PM |
|

Joined: May 24, 2004
Posts: 5994
Location: Tampere, Finland
|
|
| PORTC might work if you connected power supply to AVCC. |
|
|
| |
|
|
|
|
|
Posted: Apr 11, 2012 - 02:10 PM |
|

Joined: Nov 02, 2009
Posts: 3239
Location: Zelenograd, Russia
|
|
| Bingo! |
_________________ Warning: Grumpy Old Chuff. Reading this post may severely damage your mental health.
|
| |
|
|
|
|
|
Posted: Apr 11, 2012 - 02:20 PM |
|

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
|
| |
|
|
|
|
|
Posted: Apr 11, 2012 - 02:32 PM |
|

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.
|
| |
|
|
|
|
|
Posted: Apr 11, 2012 - 02:41 PM |
|

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
|
| |
|
|
|
|
|
Posted: Apr 11, 2012 - 02:51 PM |
|

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.
|
| |
|
|
|
|
|
Posted: Apr 18, 2012 - 01:10 PM |
|

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
|
| |
|
|
|
|
|