alternate functions of pins - how does it work?


need help about changing the function of the pins PJ0, PJ1 on my arduino-mega. thats why i think i need to understand all this overriding signal-stuff which they talk about in the atmega-manual... but i dont understand it. PJ0 and PJ1 are necessary for the serial3-connection, thats why i need them to be set to tx/rx ... Please help me about this, i dont know what to do.

here is the .pdf of the atmeaga, where i think the sollution lies (page 71, page 75 to 77 and page 94 to 97 are important imho)

For many of the alternate functions, there is code written already that manipulates the register controls as necessary. For serial3, you should only need to add

Serial3.begin(9600); in void setup.

Then just use it in void loop:

if (Serial3.available()>0){
incomingByte =;

Serial3.print ("received ");
Serial3.println (incomingByte);  // review data at also


for example.

Instead of "alternate function", which function do you want? Serial or Interrupt?

Effectively a cross-post:

In the interest of answering this in the subtly different tone than the PCInt thread....

Just about every pin on an AVR microprocessor is a digital I/O pin. There are very few exceptions -- for example, power, analog reference, reset (although on most or maybe all, reset can be repurposed as an I/O pin as well, but let's not go there yet), and the crystal in/out (which can also sometimes be reclaimed as I/O).

Some of those pins can alternatively be used as analog inputs. The Arduino library takes care of configuring the hardware to do this when you use analogRead(). Likewise, PWM requires configuration of the internal oscillators, but this is handled for you when you use analogWrite().

Others have specific purposes, like TTL serial, i2c, and SPI. Again, when you use the various library calls, they configure the hardware to behave in that fashion.

There are lots of things that can be done on certain AVR micros that the Arduino libraries don't explicitly support -- like using various clock inputs, analog comparators, JTAG, etc... These functions can still be used, but it becomes your responsibility to set up the hardware, and to verify the configuration doesn't conflict with anything the Arduino framework does. For instance, you can set the hardware timers manually, but if you do, you break things like delay() and millis(). Likewise, using some other library calls may undo manual configuration. The only way to know is to read the core libs and find out what those calls do under the hood.