Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

ATMEGA8 ports/pins

Status
Not open for further replies.

2001dragon

New Member
hey guys, I bought a ATMEGA8 to study microprocessor programming. I downloaded it datasheet but I couldn't understand the meanings of its pins names (short-form). Can anyone tell me what they are?

Thanks in advance!
 
Pin names? As in PA2? That means pin number two on port A.
Pins have numbers, ports have letters. I don´t really see what could be the trouble.
Examples, pages in datasheets, etc.. Help us help you.
 
Last edited:
PA0-7 = port A bit 0-7, PB0-7 = port B bit 0-7, PC0-7 = port C 0-7... these are the main functions. Each pin has an alternate function.

Reset input used to reset device
ADC0-7 analog to digital converter inputs
AREF input to ADC reference voltage
MISO input/output = SPI port Master In Slave Out... input when device is in master mode, ouput when device is in slave mode
MOSI input/output = SPI port Master Out Slave In
SCK input/output = SPI port clk pin output when in master mode, input in slave mode
SS SPI bus master SLAVE mode select
ICP1 input capture pin for timer/counter 1
OC1A/OC1B timer/counter 1 output compare match (A and B)
OC2 timer/counter 2 output compare match
AIN0/AIN1 analog comparator positive/negative input pins
TxD/RxD uart serial transmit and receive pins
SCL/SDA Two wire serial port clock and data in/out pins
XTAL1/XTAL2 external crystal/oscillator inputs/ oscillator output
TOSC1/TOSC2 timer oscillator inputs
T0/T1 timer/counter 0/1 external inputs
XCK USART external clock input
INT0/INT1 external interupt inputs

read pin descriptions starting on page 5. Since each pin has more than one function, the function that pin actually does is dependent on how the device is programmed. For instance, if you are using the internal RC oscillator, pins PB6 and PB7 can be used as IO port pins. If you program the device for external oscillator, there had better be a crystal attached or an external clock signal.
Alternate port pin descriptions start on page 56.

View attachment 69131
 
Last edited:
A pull up resistor is tied to the voltage plus level, and makes sure that input is a high logic level when there's no input on the pin.
Say for instance, you want to read a switch position. If you tie one side of the switch to ground, and the other to a port pin, when the switch is open, the port pin will be 'floating', so you couldn't guarantee that you'd read a logic '1'. Having a pull up resistor on the pin guarantees a logic '1' is read when the switch is open, and a logic '0' is read when the switch is closed.
The ATMEGA8 has built in pull up resistors. If you configure the port pin for input, and write a '1' to it, it turns on the pullup resistor. This way, all you need externally is the switch. Reduces parts count.
 
thanks again Mike. I will try it out.

P/S : how do I supply digital voltage to the chip? Can I use 2 1.5V battery in series as digital supply voltage?
 
Last edited:
Let me add some more info on pull-up / pull-down resistors.
The real need for a pull up is not that much of getting the pin above 1.8V (CMOS logic 1).

You could tie the pin directly to Vcc. With the switch open, the pin will be in a logic '1'.
Upon closing the switch however, a short circuit will be formed, with most likely devastating results.

This is where the pull up / down resistor comes into play. In order to limit the current to a safe level.
 
Thanks everyone!

I have 2 proximity sensors PL-05N and PL-05P. How do I connect them to ATMEGA8L and what is the state of that input pin?
 
these sensors are overkill for hooking up to a micro, as they are made to drive a relay directly, but you can still do it. Since they use a minimum of 10v, you have to take care not to blow out your micro port.

View attachment 69180

here's a suggestion:

View attachment 69181

These samples set the voltage in to 5v. For 3.3V change the 3.3K to 1.6K (or even 1.5K).
 
Last edited:
it's because of the way the sensors interface to the micro. The NPN pulls the output low, to one of the micro's rails (ground. or 0V). The PNP pulls the output up to 12V, not the micro's rail at 3.3V or 5V, so it needs an external voltage divider. Note: the unlabeled 4K7's are internal to the sensor (area in box). So the NPN uses one external resistor, while the PNP would take two external resistors.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top