Pages: [1]   Go Down
Author Topic: Accessing Ports and Pins on Arduino Due  (Read 1185 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Karma: 0
Posts: 15
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello there,
in addition to my post "LCD with Arduino Due"(maybe you can have a look at it too) in the Displays forum, I have a question about accessing pins. With atmega32 I could do things like "DDRD |= 1 << PD3;" Are there similar possibilities for the sam3x? I read a little bit in the datasheet about PIO and "thousands" of registers. I came across the PIO_Get(...) function located in the pio.c which says
"Returns 1 if one or more PIO of the given Pin instance currently have
 * a high level; otherwise returns 0.
How can i interprete that?
My initiate idea was to put all necessary pins in one union and then accessing it via a Bitmask like:
union UnionOfPins {PORTA:1; PORTB:2; PORTA:3...; int myPort} myUnionOfPins; myUnionOfPins.myPort = 0xff;
In other words I want to define my own Port or at least use the already defined Ports.
One code example with getting a LED to blink with/(preferably)without using Arduino functions would already help quite a lot I think!

Why do I ask? Because my code looks like this:
pinMode(16, OUTPUT); pinMode(15, OUTPUT); pinMode(14, OUTPUT);
pinMode(9, OUTPUT); pinMode(8, OUTPUT); pinMode(7, OUTPUT); pinMode(6, OUTPUT); pinMode(5, OUTPUT); pinMode(4, OUTPUT); pinMode(3, OUTPUT); pinMode(2, OUTPUT);

digitalWrite(14, LOW);
digitalWrite(16, LOW); digitalWrite(15, LOW);
digitalWrite(9, LOW); digitalWrite(8, LOW); digitalWrite(7, HIGH); digitalWrite(6, HIGH); digitalWrite(5, HIGH); digitalWrite(4, LOW); digitalWrite(3, LOW); digitalWrite(2,
« Last Edit: December 23, 2012, 09:10:15 am by decrux » Logged

Pages: [1]   Go Up
Jump to: