Jose, All Atmel processors (as far as I know anyway) have three registers for a port, one is for setting the output bits that you have declared output (PORTA), one is for reading the input bits you declared input (PINA) and of course, the DDRA register for setting which bits are input and which are output. This is different from other processors that use just one register for both functions. I know the Motorola processors I've used the bit in PORTA changes dependent on the definition in the DDR. Register PINA is used when you want to read the input of the port or just read a bit in the register. It reflects the input to PORTA. Register PORTA is used when you what to set bits of the port or just set a bit. If you read PORTA it is reading what is programmed in to the output register for PORTA. It all depends on how you have set DDRA, inputs or outputs as to what register you use and what you want to do with the bit. To set a bit with the bit declared output high use PORTA=PORTA|0x01;, to use your example. Or to set it low use PORTA=PORTA&0xfe; ( Most use macros here to manipulate bits as it is much more fool proof. ) To read a bit with the bit declared input use FOO=PINA&0xfe, to use your example. I'm sure these work and that you will not have any "trouble". Study of the Atmel manual for the processor you are using also helps. Maybe this is too simplified but hope it helps some, Jim ----- Original Message ----- From: "Jose Fuentes" <josecarlosfuentes@yahoo.com.ar> To: <AVR-Chat@yahoogroups.com> Sent: Sunday, April 02, 2006 11:39 PM Subject: Re: [AVR-Chat] Connecting AVRs directly to inputs of 74HC and LS logic chips. > I have a board with an AVR driving a LS chip directly, > and it works fine. But I had problems with source > code like this: > PORTA = PINA | 0x01; > It seems that under certain conditions PORTA is not > equal to PINA. I modified the code like this: > PORTA = PORTA | 0x01; > and it solved the problem. > > The first thing that comes to mind when you say that > "AVR was unable to pull the input on the logic chip > completely low" is that AVR pin was actually set as > input. That way you would be pulling high the pin by > using the internal pull-up. But you woudn't be able > to pull down the pin because it just would enter into > high impedance state. > > > > > Regards > > Jose > > > > > kernels_nz wrote: > > > Hi Guys, > > > > > > Ive had two different boards lately give a lot of > > trouble, both had > > > OUTPUTS on AVR chips connected directly to inputs > > on 74HC and 74LS > > > logic chips. > > > > > > Looking at it with my scope, it appeared that the > > AVR was unable to > > > pull the input on the logic chip completely low ? > > It would pull it to > > > around 1 to 3 volts for a low output. > > > > > > I did ensure that the pins were set up as OUTPUTS, > > nothing else > > > weird. > > > > > > Both problems were solved by connecting 100k > > resistors from the input > > > pins on the logic chips to ground. > > > > > > Any ideas ? Im sure it will be obvious as soon as > > someone points out > > > the obvious, but it's got me beat. > > > > > > Cheers > > > Hein B > > > Andante Technology > > > Auckland > > > New Zealand. > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > Yahoo! Groups Links > > > > > > > > > > > > > > > > > > > > > > -- > > ------------------------------------------------- > > Dennis Clark TTT Enterprises > > www.techtoystoday.com > > ------------------------------------------------- > > > > > > > > Yahoo! Groups Links > > > > > > AVR-Chat-unsubscribe@yahoogroups.com > > > > > > > > > > > > > __________________________________________________ > Correo Yahoo! > Espacio para todos tus mensajes, antivirus y antispam ¡gratis! > ¡Abrí tu cuenta ya! - http://correo.yahoo.com.ar > > > > Yahoo! Groups Links > > > > > > >
Message
Re: [AVR-Chat] Connecting AVRs directly to inputs of 74HC and LS logic chips.
2006-04-03 by James Hatley
Attachments
- No local attachments were found for this message.