Yahoo Groups archive

AVR-Chat

Index last updated: 2026-04-28 22:41 UTC

Thread

PORTA input problems

PORTA input problems

2004-08-27 by Jack Valmadre

Hi,
I have the outputs of a quad comparator (LM339) connected to PORT A of an
AT90S8535 on pins 0-3.
I can read pins 0 and 1 fine, but 2 and 3 are constantly read as low.  I
tried moving this to pins 4-7 and the opposite happened, so I could read
from pins 6 and 7 but not 4 and 5.  I moved the whole thing to PORT C and it
worked fine, but I cannot do this permanently as all my other ports are in
use.  I need to use all 8 pins of PORT A and I don't want to split the
connector.  The comparator outputs are pulled high by an 8.2k resistor.
I have AVCC and AREF connected to the +5V supply and AGND is connected to
0V.
I am not using the ADC but I will have to soon.
Has anyone seen this before or know how to fix it?
I have attached my program below in case it is any help.
Thanks,
Jack


#include <avr/io.h>

#define green (1<<PD1)
#define blue (1<<PD0)
#define red  ((1<<PD1)|(1<<PD0))
#define white 0

int main(void) {

 unsigned char sensors;

 DDRA = 0x00;
 DDRB = 0x00;
 DDRC = 0x00;
 DDRD = 0xFF;

 for(;;) {

  sensors = PINA & 0x0F;

  if( (sensors & (1<<0)) || (sensors & (1<<1)) ) {

   if( (sensors & (1<<2)) || (sensors & (1<<3)) ) {

    PORTD = green;

   } else {

    PORTD = blue;

   }

  } else {

   PORTD = red;

  }

 }

}

Re: [AVR-Chat] PORTA input problems

2004-08-27 by Jack Valmadre

I forgot to mention that I tested pins 0-3 on PORT A as outputs and they
worked fine.
I have also tried connecting an LED to the output of the comparator where it
would usually be connected to the Atmel and it went on/off as expected.
Jack.
Show quoted textHide quoted text
----- Original Message ----- 
From: Jack Valmadre
To: AVR-Chat@yahoogroups.com
Sent: Saturday, August 28, 2004 7:39 AM
Subject: [AVR-Chat] PORTA input problems


Hi,
I have the outputs of a quad comparator (LM339) connected to PORT A of an
AT90S8535 on pins 0-3.
I can read pins 0 and 1 fine, but 2 and 3 are constantly read as low.  I
tried moving this to pins 4-7 and the opposite happened, so I could read
from pins 6 and 7 but not 4 and 5.  I moved the whole thing to PORT C and it
worked fine, but I cannot do this permanently as all my other ports are in
use.  I need to use all 8 pins of PORT A and I don't want to split the
connector.  The comparator outputs are pulled high by an 8.2k resistor.
I have AVCC and AREF connected to the +5V supply and AGND is connected to
0V.
I am not using the ADC but I will have to soon.
Has anyone seen this before or know how to fix it?
I have attached my program below in case it is any help.
Thanks,
Jack


#include <avr/io.h>

#define green (1<<PD1)
#define blue (1<<PD0)
#define red  ((1<<PD1)|(1<<PD0))
#define white 0

int main(void) {

unsigned char sensors;

DDRA = 0x00;
DDRB = 0x00;
DDRC = 0x00;
DDRD = 0xFF;

for(;;) {

  sensors = PINA & 0x0F;

  if( (sensors & (1<<0)) || (sensors & (1<<1)) ) {

   if( (sensors & (1<<2)) || (sensors & (1<<3)) ) {

    PORTD = green;

   } else {

    PORTD = blue;

   }

  } else {

   PORTD = red;

  }

}

}


Yahoo! Groups Sponsor
ADVERTISEMENT






Yahoo! Groups Links

To visit your group on the web, go to:
http://groups.yahoo.com/group/AVR-Chat/

To unsubscribe from this group, send an email to:
AVR-Chat-unsubscribe@yahoogroups.com

Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.

Re: [AVR-Chat] PORTA input problems

2004-08-27 by Dave VanHorn

At 04:46 PM 8/27/2004, Jack Valmadre wrote:

>I forgot to mention that I tested pins 0-3 on PORT A as outputs and they
>worked fine.
>I have also tried connecting an LED to the output of the comparator where it
>would usually be connected to the Atmel and it went on/off as expected.
>Jack.

Sounds like you've done all the basics.  
Have you checked that you're actually getting the signals on the chip pins, as opposed to the socket pins, or PCB traces? I've been fooled before, with bad socket pins.

In assembler, I would set the appropriate bits in DDRA as 0 for input, set the PORTA bits high for pullups, and then IN TEMP,PINA and mask as appropriate.

Re: [AVR-Chat] PORTA input problems

2004-08-27 by Jack Valmadre

I checked the voltage on the pins and they were all 4.87-4.98V, the same as
the outputs.
Activating pull-ups didn't make any difference.
This code:
  sensors = PINA;
  sensors &= 0xF0;
didn't compile any differently to:
  sensors = PINA & 0xF0;
Jack.
Show quoted textHide quoted text
----- Original Message ----- 
From: Dave VanHorn
To: AVR-Chat@yahoogroups.com ; AVR-Chat@yahoogroups.com
Sent: Saturday, August 28, 2004 8:15 AM
Subject: Re: [AVR-Chat] PORTA input problems


At 04:46 PM 8/27/2004, Jack Valmadre wrote:

>I forgot to mention that I tested pins 0-3 on PORT A as outputs and they
>worked fine.
>I have also tried connecting an LED to the output of the comparator where
it
>would usually be connected to the Atmel and it went on/off as expected.
>Jack.

Sounds like you've done all the basics.
Have you checked that you're actually getting the signals on the chip pins,
as opposed to the socket pins, or PCB traces? I've been fooled before, with
bad socket pins.

In assembler, I would set the appropriate bits in DDRA as 0 for input, set
the PORTA bits high for pullups, and then IN TEMP,PINA and mask as
appropriate.



Yahoo! Groups Sponsor
ADVERTISEMENT






Yahoo! Groups Links

To visit your group on the web, go to:
http://groups.yahoo.com/group/AVR-Chat/

To unsubscribe from this group, send an email to:
AVR-Chat-unsubscribe@yahoogroups.com

Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.

Re: [AVR-Chat] PORTA input problems

2004-08-28 by Dave VanHorn

At 06:41 PM 8/27/2004, Jack Valmadre wrote:

>I checked the voltage on the pins and they were all 4.87-4.98V, the same as
>the outputs.
>Activating pull-ups didn't make any difference.
>This code:
>  sensors = PINA;
>  sensors &= 0xF0;
>didn't compile any differently to:
>  sensors = PINA & 0xF0;

We'd hope not!

Bad chip?

Re: [AVR-Chat] PORTA input problems

2004-08-28 by Jack Valmadre

Replaced the chip with a new one and everything worked fine.
Sorry about that.
Jack.
Show quoted textHide quoted text
----- Original Message ----- 
From: Dave VanHorn
To: AVR-Chat@yahoogroups.com ; AVR-Chat@yahoogroups.com
Sent: Saturday, August 28, 2004 2:24 PM
Subject: Re: [AVR-Chat] PORTA input problems


At 06:41 PM 8/27/2004, Jack Valmadre wrote:

>I checked the voltage on the pins and they were all 4.87-4.98V, the same as
>the outputs.
>Activating pull-ups didn't make any difference.
>This code:
>  sensors = PINA;
>  sensors &= 0xF0;
>didn't compile any differently to:
>  sensors = PINA & 0xF0;

We'd hope not!

Bad chip?


Yahoo! Groups Sponsor
ADVERTISEMENT






Yahoo! Groups Links

To visit your group on the web, go to:
http://groups.yahoo.com/group/AVR-Chat/

To unsubscribe from this group, send an email to:
AVR-Chat-unsubscribe@yahoogroups.com

Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.

Move to quarantaine

This moves the raw source file on disk only. The archive index is not changed automatically, so you still need to run a manual refresh afterward.