PORT connected to VCC,can it go wrong?

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

I have this problem. A long time ago a skill level away, I designed some simple hardware. The connector was like this:

VCC Di A C GND
VCC Do B D GND

But i need to interface it onto a connector like this

VCC D0 D1 D2 D3
D4  D5 D6 D7 GND

Can anything go wrong if one of the pins of a PORT (set to input without pullups) is hardwired directly to VCC and one to the GND?

(Yes, I know it's a bad design practice, but the hardware is already done)

Thanks...

There are pointy haired bald people.
Time flies when you have a bad prescaler selected.

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

as long as you can guarantee that it'll remain an input, you should be fine.

Writing code is like having sex.... make one little mistake, and you're supporting it for life.

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

Is there any possibility of a glitch that would cause the IO pin to be output when the AVR is booting up or in reset state?

- Jani

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

Quote:
Is there any possibility of a glitch that would cause the IO pin to be output when the AVR is booting up or in reset state?

That's the part I'm not sure of actually.

Well, the init looks like this:

DDRD = 0xFF - _BV(4) - _BV(3); // this is the second line of my init. 

There are pointy haired bald people.
Time flies when you have a bad prescaler selected.

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

Jepael wrote:
Is there any possibility of a glitch that would cause the IO pin to be output when the AVR is booting up or in reset state?

- Jani

That possibility always exists... however it is unlikely to happen. A well placed glitch on the VCC line could put the transistors into an unpredictable state, causing the wrong instruction to be executed, or the wrong data to be output.

I would suggest clipping the problem lines in the cable that connects the 2 boards to be absolutely safe.

Writing code is like having sex.... make one little mistake, and you're supporting it for life.

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

daqq wrote:
Quote:
Is there any possibility of a glitch that would cause the IO pin to be output when the AVR is booting up or in reset state?

That's the part I'm not sure of actually.

Well, the init looks like this:

DDRD = 0xFF - _BV(4) - _BV(3); // this is the second line of my init. 

I would suggest staying away from arithmatic operations when dealing with bitmasks... stick to the logical operatiosn of AND(&), OR(|) and XOR(^). this way you are less likely to get an unexpected bit being set or cleared.

Writing code is like having sex.... make one little mistake, and you're supporting it for life.

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

Quote:

I would suggest staying away from arithmatic operations when dealing with bitmasks... stick to the logical operatiosn of AND(&), OR(|) and XOR(^). this way you are less likely to get an unexpected bit being set or cleared.

I'll do that. Although AFAIK this is done by the compiler and turned into a constant, because the output is always constant.

There are pointy haired bald people.
Time flies when you have a bad prescaler selected.

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

Quite right

DDRD = 0xFF ^ (_BV(4) | _BV(3));

is much more intuitive :roll:

Jim

Your message here - reasonable rates.

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

Quote:

Quite right

Code:

DDRD = 0xFF ^ (_BV(4) | _BV(3));

is much more intuitive Rolling Eyes

Try:

DDRD = ~((1 << 4) | (1 << 3));

Much more readable!

- Dean :twisted:

Make Atmel Studio better with my free extensions. Open source and feedback welcome!

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

The AVR behaviour is undefined if the power supply is in an invalid range (slowly falling power). So you should enable the brown-out detector.

Regards
Sebastian

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

abcminiuser wrote:
Quote:

Quite right

Code:

DDRD = 0xFF ^ (_BV(4) | _BV(3));

is much more intuitive Rolling Eyes

Try:

DDRD = ~((1 << 4) | (1 << 3));

Much more readable!

- Dean :twisted:

Absolutely - but nowhere near silly enough.

Damn students these days... (mutter, mutter)

Jim

Your message here - reasonable rates.

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

Hmm...
How about

DDRD = 0xE7;

;-) Just teasing.

There are pointy haired bald people.
Time flies when you have a bad prescaler selected.

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

Close, how about

DDRD = (1 << 2) | (1 << PB7) | (1 << PA1) | (1 << NULL) | (3 << 6) | true;

?

Jim

Your message here - reasonable rates.

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

Jim:

while(DDRD!=0xE7)DDRD=rand()%256;

;-)

There are pointy haired bald people.
Time flies when you have a bad prescaler selected.

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

Here's my favorite:

uint8_t i=15,j=55,t=11;
DDRD=--i+j+++++t-i+++++i+--t-t--+++j+j--+--j-t---t++;
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

How about the fringes of ANSI C?

DDRD=??-8??'16;

If you use GCC you'll need -ansi.

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

KKP wrote:
How about the fringes of ANSI C?

DDRD=??-8??'16;

If you use GCC you'll need -ansi.

I think we have a winner. :lol: How does that work then?

Jim

Your message here - reasonable rates.

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

It dates back to the punch tape/punch card character set war. Some obscure people used a character set that didn't necessarily contain characters like square brackets, so the ansi committee added the most disgusting feature to c: Trigraphs, whith which they could insert their square brackets anyway. In the above, ??- translates to ~, and ??' translates to ^, so DDRD=~8^16;
That's what's happening next time you type

puts("bit is not one nor zero (???)");
//output: bit is not one nor zero (?]

It's a compatibility feature that's best disabled by default.