Society of Robots - Robot Forum

Software => Software => Topic started by: bakil on June 22, 2007, 02:37:17 PM

Title: atmega16L
Post by: bakil on June 22, 2007, 02:37:17 PM
ok i read a little part of the sheet (info of the chip) so now i wanted to ask what the ports of the atmega16l are for (B7 / B0 for example) in plain english (so even a total noob can understand it)
Title: Re: atmega16L
Post by: Ro-Bot-X on June 22, 2007, 03:35:09 PM
Quote
Port B is an 8-bit bidirectional I/O port with internal pull-up resistors (selected for each
bit). The Port B output buffers have symmetrical drive characteristics with both high sink
and source capability. As inputs, Port B pins that are externally pulled low will source
current if the pull-up resistors are activated. The Port B pins are tri-stated when a reset
condition becomes active, even if the clock is not running.
Port B also serves the functions of various special features of the ATmega16 as listed
on page 58.

You want this to be translated? Or the functions listed on page 58?

Ok, I'll try to translate this and maybe later the functions.

The first sentence states that Port B is basically an 8 bit or 1 byte port that can be set as input or output. It also state that it has internal pull-up resistors selectable for all or each bit (pin).
The second sentence states that used as output, Port B has buffers that can source (provide current, like connecting something to power) or sink (absorb current, like connecting something to ground).
The third sentence warns you that when used as input, Port B pins that are connected externally to the ground (directly or through a resistor) and have the internal pull-up resistor activated will have a current going towards the ground (directly or through the resistor). This is a waste of power, bad for a robot.
The fourth sentence states that Port B pins will be disconnected from the circuit (state Z, high impedance) when the reset pin will be triggered (usually pulled low - connected to the ground). More about tri-state on the link below:

http://www.cs.umd.edu/class/spring2003/cmsc311/Notes/CompOrg/tristate.html (http://www.cs.umd.edu/class/spring2003/cmsc311/Notes/CompOrg/tristate.html)

Does this help?
Title: Re: atmega16L
Post by: bakil on June 23, 2007, 01:41:26 AM
ik this helps thks :p
Title: Re: atmega16L
Post by: bakil on June 24, 2007, 01:19:46 PM
just a question is it possible to set a pin of portb to in and another one of portb to out
Title: Re: atmega16L
Post by: rgcustodio on June 25, 2007, 11:55:47 AM
It depends on the definitions of the channels. Generally, yes you can set one channel to INPUT only while the other is OUTPUT only.

Open the data sheet of the part (ATmega8, ATtiny13, etc) that you are using then find "Alternate Functions of Port X". This section will give you the definitions of the functionality of Port "X", some channels are INPUT only some are OUTPUT only, some have dual roles, able to become INPUT or OUTPUT. Common sense dictates that you can not set an INPUT only channel to OUTPUT.
Title: Re: atmega16L
Post by: iNFINITE on June 26, 2007, 06:57:30 AM
@bakil

Yes you can..
For PortB you should write 1 in the corresponding bit in DDRB register to configure the xorresponding pin as output. For configuring a pin as input just write the corresponding bit as 0.

For example: You want to use PB0,PB1,PB2,PB3 as input and PB4,PB5,PB6,PB7 as output then you should write DDRB=0xF0

Title: Re: atmega16L
Post by: Admin on June 27, 2007, 07:38:05 PM
I use google to do that for me . . .

for example:
DDRB = 0xC7;  //configure B ports 0, 1, 2, 6, 7 for output

(google search '0b11000111 to hex' (http://www.google.com/search?hl=en&safe=off&rls=DGUS%2CDGUS%3A2006-11%2CDGUS%3Aen&q=0b11000111+to+hex))
Title: Re: atmega16L
Post by: iNFINITE on July 01, 2007, 07:33:47 AM
You can also use the "calculator" program in Windows. Switch to scientific view. Select Binary, type 11000111, then select hex, it will show C7.