Pages: [1]   Go Down
Author Topic: Ports on the Due?  (Read 561 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 6
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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! smiley
Logged

Offline Offline
Newbie
*
Karma: 1
Posts: 42
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Logged

UK
Offline Offline
God Member
*****
Karma: 1
Posts: 530
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Same here

http://forum.arduino.cc/index.php?topic=182874.msg1354884#msg1354884
http://forum.arduino.cc/index.php?topic=182704.msg1355190#msg1355190

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.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 6
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thank you very much!

http://forum.arduino.cc/index.php?topic=155431.0

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

        for(k=34;k<=41;k++)
        {
          pinMode(k, OUTPUT);
        }
        REG_PIOC_OWER = 0x000003FC;

Thank you both for responding so quickly!
Logged

UK
Offline Offline
God Member
*****
Karma: 1
Posts: 530
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Pages: [1]   Go Up
Jump to: