#include int main() { PIOB->PIO_PER = 1u << 27; // pin controlled by pio PIOB->PIO_OER = 1u << 27; // pin as output PIOB->PIO_CODR = 1u << 27; // pin low /* read & write !*/ PIOB->PIO_ABSR = 1u << 27; // select peripheral b TC0->TC_CHANNEL[0].TC_CCR = TC_CCR_CLKDIS; // Counter Clock Disable Command TC0->TC_CHANNEL[0].TC_CMR = TC_CMR_WAVE | // Waveform mode is enabled TC_CMR_WAVSEL_UP_RC | // UP mode with automatic trigger on RC Compare TC_CMR_TCCLKS_TIMER_CLOCK1 | // MCK/2 TC_CMR_EEVT_XC0 | // Use xc0 as external event instead of TIOB so that TIOB can also be used as an output. TC_CMR_BCPB_SET | TC_CMR_BCPC_CLEAR; // Toogle TIAB output on RC Compare TC0->TC_CHANNEL[0].TC_RB = SystemCoreClock / 2; TC0->TC_CHANNEL[0].TC_RC = SystemCoreClock; TC0->TC_CHANNEL[0].TC_CCR = TC_CCR_CLKEN | TC_CCR_SWTRG; // Counter Clock Enable and Software Trigger Command return 0; }