Ports on the Due?

Hello everyone,

I am pretty new to Arduino, and brand new to the Due. I have already begun a program using the Arduino Mega2560 and a TFT display w/ capactive touch panel. The program I have is fully functional (with the Mega2560) but unfortunately the Mega2560 only has 8KB of SRAM, and only runs at 16MHz. So, in order to write to the display much faster, and also have more SRAM for storing bitmap arrays, I got the Due. (The 3.3V operating voltage is also nice) Now, I have already downloaded the newer IDE (1.5.1r2 because the 1.5.2 download didn't work) and I am having some issues that I cannot seem to figure out. In my code for the Mega, I have a function (for example) like this:

void TFT_Write_Command(unsigned char command) { PORTA = command; digitalWrite(RS, LOW); digitalWrite(WR, LOW); digitalWrite(WR, HIGH); delay(1); }

Of course the error comes up right away that 'PORTA' was not declared in this scope.

I am just trying to use my already written code on the Due for the reasons mentioned above, and need to be able to send out 8-bit parallel data to the display. I have been searching for information on this and can't seem to really find the answer I'm looking for.

If anyone could offer some solutions/suggestions I would really appreciate it! :)

finding information is actually quite easy:

searching for "parallel pin output due" yields: http://forum.arduino.cc/index.php?topic=172916.0

searching for "port manipulation due" yields: http://forum.arduino.cc/index.php?topic=181766.0 and http://forum.arduino.cc/index.php?topic=175617.0 and http://forum.arduino.cc/index.php?topic=155431.0

hope one of them helps

Same here

Port manipulation on the SAM chips is very different - instead of writing 1s and 0s to the corresponding bit in each port register, you set a ‘flag’ which turns the pin on or off, as you’ll see in those threads.

Thank you very much!

That was the link that helped me out, thanks again.

For reference that same function I had before is now

void TFT_Write_Command(unsigned char command)
REG_PIOC_ODSR = command << 2;
digitalWrite(RS, LOW);
digitalWrite(WR, LOW);
digitalWrite(WR, HIGH);

…and this in setup

pinMode(k, OUTPUT);
REG_PIOC_OWER = 0x000003FC;

Thank you both for responding so quickly!

Glad you got it sorted...

By the way, if you're doing this because you're beginning learning a more powerful IDE such as Atmel Studio, then the Atmel Software Framework (ASF) has functions built in that behave like DigitalWrite do in the Arduino core.