Arduino Due Assembly problem

I made this code, is a simple blink, but something is wrong. I want a blink for an Arduino due...

#include "sam.h"

#define LED_PIN 0x00000000u     // LED pin PB27
#define NLED_PIN 0xf7ffffffu    // LED pin PB27

void delay1(unsigned long int x);

int main(void)
{
  /* Initialize the SAM system */
  SystemInit();
  WDT -> WDT_MR = WDT_MR_WDDIS; 

  PIOB ->PIO_PER |= LED_PIN; 
  PIOB ->PIO_OER |= LED_PIN; 
  PIOB ->PIO_PUDR |= LED_PIN; 
  PIOB ->PIO_OWER = LED_PIN;

  while (1)
  {
    PIOB ->PIO_ODSR |= LED_PIN;
    delay1(1000);
    PIOB ->PIO_ODSR &= NLED_PIN;
    delay1(1000);
  }
  return 0;
}

void delay1(unsigned long int x)
{
  unsigned long int i = 0, j = 0;
  for (i = 0; i <= 1000; i++)
  {
    for (j = 0; j <= 1000; j++)
    {
      asm("nop");
    }
  }
}

I can't get the blink and I don't see the problem. The compiler shows me no problem.
I hope someone here could help me.

The title of your thread means you want to program your DUE in assembly (?), but your code is (more or less) port registers manipulation. We tend to keep inline assmbly programming for very limited snippets when port register manipulation doesn't give the maximum expected speed, which is rare.

To get started with ARM, and arduino, upload example sketchs provided in your IDE environment : Files>Example > Basics > Blink and so on.

Anyway, if you want a blink example with registers programming, you can try this based on your previous code:

// Header files are already included in the Arduino IDE
//#include "sam.h"

# define TIMESTAMP  (1000)

// Use setup() and loop() as defined by Arduino IDE instead of main()
void setup()
{
  // Initialization of uc already done in Arduino IDE
  
  //WDT -> WDT_MR = WDT_MR_WDDIS;    // by default, Watchdog is disabled

  PIOB ->PIO_PER |= PIO_PER_P27;     // PB27 is controlled by the GPIO
  PIOB ->PIO_OER |= PIO_OER_P27;     // PB27 Output enable
  //PIOB ->PIO_PUDR |= PIO_PUDR_P27;  // Pull-up disable not useful for a simple blink
  PIOB ->PIO_OWER |= PIO_OWER_P27;    // Write enable for PB27
}

void loop() {

  static // Keep the value of previous_millis after each loop
  uint32_t previous_millis = millis();
  
  if (millis() - previous_millis > TIMESTAMP) {
    PIOB->PIO_ODSR ^= PIO_ODSR_P27;  // XOR
    previous_millis = millis();
  }

  /* Alternatively, you can use the delay function
    PIOB->PIO_ODSR ^= PIO_ODSR_P27;  // XOR
    delay(1000);  // Wait 1000 ms
  */
}

// You already have a delay() function in the Arduino IDE
/*
  void delay1(uint32_t x)
  {
  uint32_t i = 0, j = 0;
  for (i = x; i > 0; --i)
  {
    for (j = x; j > 0; --j)
    {
      __asm__ __volatile__("nop");
    }
  }
  }
*/

Albert013:
I made this code, is a simple blink, but something is wrong. I want a blink for an Arduino due...

void delay1(unsigned long int x)

{
  unsigned long int i = 0, j = 0;
  for (i = 0; i <= 1000; i++)
  {
    for (j = 0; j <= 1000; j++)
    {
      asm("nop");
    }
  }
}




I can't get the blink and I don't see the problem. The compiler shows me no problem.
I hope someone here could help me.

I believe that your issue is that you didn't say that the NOP was volatile. Not specifying this means that the compiler is free to optimize it. Guess what the most efficient form of NOP is??? Nothing. It just takes it out. With the nop gone the loops are then irrelevant and they disappear too. The compiler then congratulates itself on saving a ton of cycles. Instead you should use:

asm volatile ("nop");

This tells the compiler that the instruction(s) found in the asm directive have important side effects and shouldn't be removed. In some cases volatile asm instructions can still be relocated or rearranged a bit but they won't disappear.

#define LED_PIN 0x00000000u     // LED pin PB27

Shouldn't there be a "1" bit in there somewhere?