Pages: [1]   Go Down
Author Topic: Cannot Program Due in Assembly / use PINx commands with Due in 1.5.2  (Read 376 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 1
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello,
   I just down loaded 1.5.2 and tried to run a code I had written for high speed channel switching square wave for the Uno on my new Due.
void setup() {
 DDRB = 0xff;
 DDRD= 0xff;
 
 
 }
 void loop() {
   int state=0;
   int i=4;
   while(1)
    {
      while(i!=0)
      {
       
      PORTB&=~0x20;
      PORTB&=~0x10;
     // PORTB= 0xff;
     __asm__("nop\n\t""nop\n\t""nop\n\t""nop\n\t");
     
      PORTB|=0x10;
      PORTB|=0x20;
     
      //PORTB=0x00;
   
      i--;
      }
     
      delay(1);
      i=4;
    }
 }


I receive an error something like
ketch_aug15c.ino: In function 'void setup()':
sketch_aug15c:8: error: 'DDRD' was not declared in this scope
sketch_aug15c.ino: In function 'void loop()':
sketch_aug15c:13: error: 'PORTD' was not declared in this scope

Is anyone else having this issue? / what am I doing wrong?
 
Logged

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

First off, when you post code - use the code tags, helps keep everything much neater.

Now, on to the problem - it seems you're trying to program the Due with code that directly manipulates registers such as referencing 'DDRB' - if this is the case, don't hope for it to work. Data Direction Registers, and PORTx etc is all from the 8-bit AVR chips found on the Uno, Mega, Nano etc - it's completely irrelevant on the 32-bit ARM based SAM devices, instead - they use PIO controllers etc. Have a read through the datasheet for the 3X8E, and you'll see no reference whatsoever to a DDRB.

It seems a lot of people are getting confused at the moment trying to port AVR code to SAM, the architecture is completely different. The Arduino team have simply written new cores, so that things like digitalWrite all work the same - but the source code behind them is very different.

See this topic - http://forum.arduino.cc/index.php?topic=182704.0

Quote
high speed channel switching square wave

Do you mean you're trying to create a PWM waveform? - and send that to an Uno board? Tell us a little more and we'll do what we can to help...
« Last Edit: August 15, 2013, 05:00:16 pm by jtw11 » Logged

Pages: [1]   Go Up
Jump to: