Problem with input

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

Hello

I have a problem with my inputs.

The input PC0 - PC1 - Nc6 - PC7 work fine

Only the inputs 2 to 5 do not work.

Here a little script how I've described my input

DDRC = 0x00;
PORTC = 0xff;

If (PINC == 0b00000001)
{
}

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

Quote:

If (PINC == 0b00000001)

So, you expect >>all<< bits of a port to have the exact value of your bit mask?

How are you testing? What are the results? (and don't just say "doesn't work")

What AVR model are you working with?

What are the alternate functions of the pins that "don't work"? JTAG, perhaps?

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

This sound as a suspicious JTAG issue, those pins are used i.e. for mega164.
Disable JTAG fuse and see if that helps.

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

Thank you!

I use the ATmega32!

And it's true! They are exactly the same ports on the jtag, and these do not work!

Thanks, I was not himself come up!

Greetings

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

To expand on Lee's point. If you had used the more obvious:

if (PINC & (1<<PC0)) {

then the code would have worked even if pins 4,5,6,7 were being used for JTAG. The use of & lets you pick out 1 bit from the byte and ignore the others. If you don't understand this read the "Bit manipulation 101" article in the tutorial forum.