Yahoo Groups archive

AVR-Chat

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

Message

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;

  }

 }

}

Attachments

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.