Arduino due digital output

can arduino due generate a pulse signal with 125 khz and what is the code

very easy

digitalWrite(pin_number, HIGH);
digitalWrite(pin_number, LOW);

thank you for your replay but it does no work i used this cod before

void setup() {
// initialize digital pin 13 as an output.
// Serial.begin(115200);
pinMode(5, OUTPUT);
}

// the loop function runs over and over again forever
void loop() {
digitalWrite(5, LOW); // turn the LED on (HIGH is the voltage level)
delayMicroseconds(1); // wait for a second
digitalWrite(5, HIGH); // turn the LED off by making the voltage LOW
delayMicroseconds(1); // wait for a second
}

replace delayMicroseconds(1) into delay(1000).

delayMicroseconds(1) - this is 1 microsecond. You can't see blink )
delay(1000) - this is 1000 milliseconds = 1 second

Hi husseinUKM,

The following code will output a 125kHz square wave with a 50% duty cycle, on pin DAC1:

// Output a 125kHz PWM waveform at a resolution of 9-bits on pin DAC1 (PWML0)
void setup() {
  // PWM Set-up on pin: DAC1
  REG_PMC_PCER1 |= PMC_PCER1_PID36;                     // Enable PWM 
  REG_PIOB_ABSR |= PIO_ABSR_P16;                        // Set PWM pin perhipheral type A or B, in this case B
  REG_PIOB_PDR |= PIO_PDR_P16;                          // Set PWM pin to an output
  REG_PWM_CLK = PWM_CLK_PREA(0) | PWM_CLK_DIVA(1);      // Set the PWM clock rate to 84MHz (84MHz/1) 
  REG_PWM_CMR0 = PWM_CMR_CPRE_CLKA;                     // Enable single slope PWM and set the clock source as CLKA
  REG_PWM_CPRD0 = 672;                                  // Set the PWM frequency 84MHz/125kHz = 672 
  REG_PWM_CDTY0 = 336;                                  // Set the PWM duty cycle 50% (672/2=336)
  REG_PWM_ENA = PWM_ENA_CHID0;                          // Enable the PWM channel     
}

void loop() {}

delayMicroseconds functions are not accurate you cannot use it for time critical things.

thank you very much for your help MartinL

can arduino due read analog signal with 125 KHz also?