Can pull a pin low?

Go To Last Post
8 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I seem to have a predicament I cant solve.

I have a atmega168 and I'm running some code like so.

while(1)
{
PORTB &= ~0x3f;//
DDRB |= 0x3f;
}
PORTB &= ~0x3f;//
DDRB |= 0x3f;
while(1)
{
}
or


The code is not intentional, its just to help me figure out what wrong here. I have the neg. lead of an led connected to each pin on the B port and then to a power source.

0 Led comes on, no other electronics on this pin
1 Led comes on, no other electronics on this pin
2 Led does not come one, no other electronics//
3 Led does not come one, no other electronics//
4 Led does not come one, but there is a pull-up.
5 Led does not come one, no other electronics
6 used for my crystal
7 used for my crystal

Now pinb.0 is on the left side of the chip and pinb.1 is on the right, so I guess its not a power issues on one side or the other. Not to mention all of pinc works when I tested it.

The kicker. If I take a piece of wire and short pinb.1 to pinb.2 ( on the chips its self )led2 now comes on. So as far as I can tell the chip/code is simply not pulling the pin low. How could that be possible?

I have switched out the chip, and tested the pin directly, so I know its not a bad solder connection. Is there something dumb in my code up above?

I have tried other varies like

while(1)
{
PORTB = 0;//
DDRB = ff;
}

but still get the same results.

I did forget to add that I'm able to pull high. If I flip the LEDs and pull high on all pins they all work.

Last Edited: Mon. Mar 8, 2010 - 10:35 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Show your entire test program. Also, be sure to disconnect your ISP programmer. (The symptoms sound like you may have alternate functions of some of the pins enabled, e.g. SPI.)

You can put lipstick on a pig, but it is still a pig.

I've never met a pig I didn't like, as long as you have some salt and pepper.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:
I have the neg. lead of an led connected to each pin on the B port and then to a power source.

Nothing to do with the code, but I assume you have a resistor in series with your LEDs...

JC

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:
I assume you have a resistor in series with your LEDs...
..hey...that line is copyrighted!!

John Samperi

Ampertronics Pty. Ltd.

www.ampertronics.com.au

* Electronic Design * Custom Products * Contract Assembly

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

i can't prove/see that you are controlling PORTB and DDRB properly, espcailly PORTB. just set them to the values you want in the while(1) loop, or show us ALL the code that precedes the while(1) loop.
also make sure JTAG is disabled if it can affect portb.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Yes I have resistor, and yes the programmer is detached, I too immediately expected that.

theusch's comment got me thinking..

I dimmed the lights and close all windows and I see a faint light. Not as strong as the other, the voltage source is at the same potential. So I moved my test code at the top of my maim, above my SPCR code.... Should have though of that.. and i get a lit led, but below it I do not. Makes sense though.

The reason for the dim light was a mistake on my part, just figure I'd see it. I need to stick with working in the dark more often.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:
working in the dark more often.
We always work in the dark when trying to answer questions here. :)

John Samperi

Ampertronics Pty. Ltd.

www.ampertronics.com.au

* Electronic Design * Custom Products * Contract Assembly

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Yes the dark side is always better because evil is cool and good is stupid. - SpaceBalls