Using : MBDToolbox 4.2.1,with hotfix for register access blocks.
Using: S32K144 LQFP-100, on proprietary hardware board
The dropdown box for XTAL Frequency does not display the option to use the onboard oscillator module; the "External 8" option misleadingly suggests it is for an external oscillator, but actually configures the onboard oscillator module.
When the block is configured as "External 8", the following code is generated in the s32k_clock_init.c file:
.soscConfig =
{
.initialize = true, /* Initialize */
.freq = XTAL_FREQ, /* Frequency */
/* SOSCCSR */
.monitorMode = SCG_SOSC_MONITOR_DISABLE,/* SOSCCM */
.locked = false, /* LK */
/* SOSCCFG */
.extRef = SCG_SOSC_REF_OSC, /* EREFS */
.gain = SCG_SOSC_GAIN_LOW, /* HGO */
.range = SCG_SOSC_RANGE_HIGH, /* RANGE */
/* SOSCDIV */
.div1 = MBDT_SOSCDIV,/* SOSCDIV1 */
.div2 = MBDT_SOSCDIV,/* SOSCDIV2 */
},
This configures the SOSC module with EREFS=1, which selects the internal oscillator amplifier module as the source of the clock (instead of the external reference clock on pin EXTAL).
Page 90 of the S32 reference manual (4.5.1) states
NOTE
If oscillator is enabled then enabling the GPIO or LPI2C
function for EXTAL/XTAL pins can lead to device damage.
This must be avoided by software.
I am using an external oscillator (square wave) to drive the EXTAL pin, and I dodged a bullet here as I did not connect XTAL on my board or configure any I/O on the pin.
The current options should be relabelled as "Internal crystal oscillator 8", and new options for "External Oscillator 8" should be added which set EREFS=0.
Additonally, it would be good to issue a warning when the internal oscillator is used with a link to seciton 4.5.1 of the manual and that the EXTAL/XTAL pins should not be configured for use by any peripherals other than the SOSC module.