1Mhz clock on arduino nano 33 ble

Welcome to the forum.

You can use a timer and the PPI system to create a signal at an IO pin without any software intervention after the initial configuration.

Here is an example. This is not a beginners tutorial. You will need to read the nRF datasheet if you want to do major modifications. This might also break other functionality that makes use of the timer and ppi channel.

/*
  This example shows how to use a nRF52840 Timer and PPI to create square wave signal at a pin.
  The signal is created by hardware and does not require any software after initialization.
  Note:
  - two samples are needed for a full wave
  - to create 1 MHz the SAMPLES_PER_SECOND need to be 2M
  - check pin diagram in Arduino store for nRF pins and ports
  
  The circuit:
  - Arduino Nano 33 BLE/ BLE Sense board.

  This example code is in the public domain.
*/

#include "mbed.h"

#define SAMPLES_PER_SECOND  (2000000)
#define PPI_CHANNEL_T4      (7)

// Arduino Nano 33 BLE Digital pin D10 P1.02
#define PIN_GPIO_T4         (2)
#define PORT_GPIO_T4        (1)

void setup()
{
  initTimer4();
  initGPIOTE();
  initPPI();
}

void loop()
{
  
}


void initTimer4()
{
  NRF_TIMER4->MODE = TIMER_MODE_MODE_Timer;
  NRF_TIMER4->BITMODE = TIMER_BITMODE_BITMODE_16Bit;
  NRF_TIMER4->SHORTS = TIMER_SHORTS_COMPARE0_CLEAR_Enabled << TIMER_SHORTS_COMPARE0_CLEAR_Pos;
  NRF_TIMER4->PRESCALER = 0;
  NRF_TIMER4->CC[0] = 16000000 / SAMPLES_PER_SECOND; // Needs prescaler set to 0 (1:1) 16MHz clock
  NRF_TIMER4->TASKS_START = 1;
}


void initGPIOTE()
{
  NRF_GPIOTE->CONFIG[0] = ( GPIOTE_CONFIG_MODE_Task       << GPIOTE_CONFIG_MODE_Pos ) |
                          ( GPIOTE_CONFIG_OUTINIT_Low     << GPIOTE_CONFIG_OUTINIT_Pos ) |
                          ( GPIOTE_CONFIG_POLARITY_Toggle << GPIOTE_CONFIG_POLARITY_Pos ) |
                          ( PORT_GPIO_T4                  << GPIOTE_CONFIG_PORT_Pos ) |
                          ( PIN_GPIO_T4                   << GPIOTE_CONFIG_PSEL_Pos );
}


void initPPI()
{
  // Configure PPI channel with connection between TIMER->EVENTS_COMPARE[0] and GPIOTE->TASKS_OUT[0]
  NRF_PPI->CH[PPI_CHANNEL_T4].EEP = ( uint32_t )&NRF_TIMER4->EVENTS_COMPARE[0];
  NRF_PPI->CH[PPI_CHANNEL_T4].TEP = ( uint32_t )&NRF_GPIOTE->TASKS_OUT[0];

  // Enable PPI channel
  NRF_PPI->CHENSET = ( 1UL << PPI_CHANNEL_T4 );
}