MKMxxZxxACxx5 Bare Metal Software Drivers  R4.1.6
Reference Manual
AFE Clocked by 8.0 MHz OSC, FEE Mode

This example shows System Oscillator (OSC), controlled by 8.0 MHz External Crystal, as the direct clocks source of the Analogue Front End (AFE) module. The FLL module is configured to operate in FEE mode generating 20.0 MHz (8.0 MHz / 256 * 640) Core clock and 10.0 MHz Bus/Flash clocks.

The 4.0 MHz 50% duty-cycle sigma delta modulator clock, derived from 8.0 MHz External Crystal, is routed to pin PTB7 for monitoring purposes.

Source code:
/******************************************************************************
* (c) Copyright 2010-2015, Freescale Semiconductor Inc.
* ALL RIGHTS RESERVED.
******************************************************************************
* oscafe_test.c
******************************************************************************/
#include "drivers.h"
/* global data definitions */
volatile int32 result;
void main (void)
{
/* enable clocks to all peripherals - clock mode 2:1:1 (core:bus:flash) */
/* route bus clock to PTF7 */
/* configures AFE_CLK pad to output mode and routes it to PTB7 */
/* system oscillator and FLL settings */
/* VREF module must be initialized after SIM module */
VREFL_Trim( 3); /* VREFL trimmed to 0.400 V */
/* afe clocking directly from system oscillator */
/* trigger AFE operation by SW */
/* main loop */
while (1)
{
{
AFE_Read (CH1, &result);
}
}
}
Toolchain support:
IAR EWARM 7.40.7CodeWarrior 10.6KEIL uVision 5.15CrossWorks 3.6ATOLLIC TrueStudio 5.3.0Kinetis Design Studio 3.0.0