Working with the ports and related similar stuff

hi all looking for some advice on were to go / book on working with the ports in arduino. I know i can understand it but the pages ive looked at skipped through the topic quite fast. I have read the arduino page several times and various other bit's i've found on google. what i could really do with is a comprehensive explanation of it for the arduino for a complete novice. I have some experience of c/c++ a few city&guilds certificates. Basically so i'm sure what i think i know is right and it doesn't miss anything out. If it then went on to start to explane how to use things like timer interrupts as well that would be great. I need more than the one web page i can find on the arduino site.

A Good resource may be

Ah good link but i'm ok with most of that i think. Maybe i wasn't clear it's this type if thing What i want is a more comprehensive ( more long winded , ports for dummys?) explanation with more examples and like i said going on to interups would be good. I'm not a natural when it comes to hex but i'm getting there a book or site with more than one page is what i'm after.

I'd suggest for you, to dig information not only with "arduino" in the google search line, but a bit wider. For example:

"AVR Microcontroller and Embedded system" "C programming for microcontrollers" "Programming Interactivity"

There is, that provide specification on ATMega328p (.pdf) plus a bunch of application notes. Sure, you will find more than 100 pages, that explain how interruption works, as well as timers, PWM, ADC, ALU/CPU etc.

But isn't the way the ports are set up different for different systems and different chips? I don't really have the time at the minute to learn about all micro controllers (beyond the very basic's which ive all ready read a lot of) . I've looked at the avr documentation but it seems like their needs to be a step in between this and the arduino for me. The idea is that i will take a project ive developed on the arduino and re wright it in avr c++ using most of the class's ive created in arduino. I wanted to do some port manipulation and interrupt stuff before i get to the avr compiler stage though as at the minute i use the standard read/wright pin stuff. I will figure it out i'm sure from what ive all ready got but i'm sure there must be a book out their somewhere that covers these topics. I like to go in small step's.

actually Magician good call on the links

But isn't the way the ports are set up different for different systems and different chips?

No, the mapping is taken care of by the Arduino wrapper.

Can you maybe quit rambling, and state concisely and clearly what it is you are trying to get us to do for you?

i'm sure there must be a book out their somewhere that covers these topics.

Google is probably your best bet to find that book. You might check in the below forum.

Well if you understand how to use direct port manipulations then all you need is the below linked document that shows arduino pin mapping from/to arduino pin number to numbers of two of the popular arduino chip series. This can result in faster execution of sketches using I/O pins, but at the expensive of losing some portablity of the sketch between boards using different avr chips.


That looks very useful retolefty thanks. I’m sorry for rambling groove iwas trying to be as clear as i could
it’s these types of statements i was wanting a breakdown of. I’m sure it’s simple but they mean nothing to me at the minute.

PORTD |= 00010000; // think i’m ok with what all this means now

const int portBit = 4;
PORTD |= (1 << portBit); // want to know what this does and why

PORTD &= ~(1<<portBit); // same with this

there are more ive seen and as far as i know nothing very complicated is going on. I can just copy bits from other but i want to know why it’s working. At the risk of rambling to much i’ll leave it there.

Look at the bit operators.

With that information, you can figure out what the three PORTD assignment statements are setting PORTD to. The, when you understand the relationship between PORTD and some pins on a specific Arduino, you can see how you are setting all the pins on some port (D) at one time, to what values. Then, you can modify what you are setting PORTD to to achieve your specific (unstated, understandably) goal.