If the platform is already stable, you can just build this. If you're bootstrapping a platform you might need to build this with configBSP430_CONSOLE set to 0 so that the clock signals are exposed without attempting to create a serial port (which probably won't work if the clocks aren't what you expect).
#if (BSP430_CONSOLE - 0)
#endif
#include <stdlib.h>
void main ()
{
#if (BSP430_CONSOLE - 0)
const char * help;
unsigned long smclk_Hz;
unsigned long aclk_Hz;
#endif
}
#if (BSP430_CONSOLE - 0)
cputtext(
"\nclocks " __DATE__
" " __TIME__
"\n");
cputtext(
"\nBSP430_PLATFORM_BOOT_CONFIGURE_LFXT1: ");
cputtext(
"\nBSP430_CLOCK_LFXT1_STABILIZATION_DELAY_CYCLES: ");
cputtext(
"\nBSP430_PLATFORM_BOOT_LFXT1_DELAY_SEC: ");
cputtext(
"\nBSP430_PLATFORM_BOOT_CONFIGURE_CLOCKS: ");
#if defined(__MSP430_HAS_BC2__)
#if (configBSP430_BC2_TRIM_TO_MCLK - 0)
cputtext(
"\nconfigBSP430_BC2_TRIM_TO_MCLK: 1");
#else
cputtext(
"\nconfigBSP430_BC2_TRIM_TO_MCLK: 0");
#endif
#if (BSP430_BC2_TRIM_TO_MCLK - 0)
cputtext(
"\nBSP430_BC2_TRIM_TO_MCLK: 1");
#else
cputtext(
"\nBSP430_BC2_TRIM_TO_MCLK: 0");
#endif
#endif
#if defined(__MSP430_HAS_UCS__) || defined(__MSP430_HAS_UCS_RF__)
#if (configBSP430_UCS_TRIM_DCOCLKDIV - 0)
cputtext(
"\nconfigBSP430_UCS_TRIM_DCOCLKDIV: 1");
#else
cputtext(
"\nconfigBSP430_UCS_TRIM_DCOCLKDIV: 0");
#endif
#if (BSP430_UCS_TRIM_DCOCLKDIV - 0)
cputtext(
"\nBSP430_UCS_TRIM_DCOCLKDIV: 1");
#else
cputtext(
"\nBSP430_UCS_TRIM_DCOCLKDIV: 0");
#endif
#endif
cputtext(
"\nBSP430_CLOCK_PUC_MCLK_HZ: ");
cputtext(
"\nBSP430_CLOCK_NOMINAL_MCLK_HZ: ");
cputtext(
"\nBSP430_CLOCK_LFXT1_IS_FAULTED_NI(): ");
cputtext(
"\nBSP430_CLOCK_NOMINAL_VLOCLK_HZ: ");
cputtext(
"\nBSP430_CLOCK_NOMINAL_XT1CLK_HZ: ");
#if defined(BSP430_CLOCK_NOMINAL_XT2CLK_HZ)
cputtext(
"\nBSP430_PLATFORM_BOOT_CONFIGURE_XT2: ");
cputtext(
"\nBSP430_CLOCK_XT2_IS_FAULTED_NI(): ");
cputtext(
"\nBSP430_CLOCK_NOMINAL_XT2CLK_HZ: ");
#endif
cputtext(
"\nulBSP430clockMCLK_Hz_ni(): ");
cputtext(
"\nBSP430_PLATFORM_BOOT_SMCLK_DIVIDING_SHIFT: ");
cputtext(
"\nulBSP430clockSMCLK_Hz_ni(): ");
cputtext(
"\nBSP430_PLATFORM_BOOT_ACLK_DIVIDING_SHIFT: ");
cputtext(
"\nulBSP430clockACLK_Hz_ni(): ");
#if (BSP430_TIMER_CCACLK - 0)
if (1000000UL <= aclk_Hz) {
cputtext(
"\nUnable to use high-speed ACLK for differential timing of SMCLK");
} else {
do {
const unsigned int SAMPLE_PERIOD_ACLK = 10;
unsigned int cc_delta;
unsigned long aclk_rel_smclk_Hz;
unsigned long smclk_rel_aclk_Hz;
if (! tp) {
cputtext(
"\nUnable to access configured CCACLK timer");
break;
}
SAMPLE_PERIOD_ACLK);
if (-1 == cc_delta) {
cputtext(
"\nCCACLK measurement failed");
break;
}
cputu(SAMPLE_PERIOD_ACLK, 10);
cputtext(
"\nComparison with measured values:");
cputtext(
"\n SMCLK (Hz) (if measured ACLK correct): ");
smclk_rel_aclk_Hz = (cc_delta * aclk_Hz) / SAMPLE_PERIOD_ACLK;
cputul(smclk_rel_aclk_Hz, 10);
cputl(smclk_rel_aclk_Hz - smclk_Hz, 10);
cputl(1000 * labs(smclk_rel_aclk_Hz - smclk_Hz) / smclk_Hz, 10);
cputtext(
"\n ACLK (Hz) (if measured SMCLK correct): ");
aclk_rel_smclk_Hz = SAMPLE_PERIOD_ACLK * smclk_Hz / cc_delta;
cputul(aclk_rel_smclk_Hz, 10);
cputl(aclk_rel_smclk_Hz - aclk_Hz, 10);
cputl(1000 * labs(aclk_rel_smclk_Hz - aclk_Hz) / aclk_Hz, 10);
} while (0);
}
#else
cputtext(
"\nNo CCACLK timer available for ACLK/SMCLK comparison");
#endif
#if defined(__MSP430_HAS_BC2__)
#endif
#if defined(__MSP430_HAS_FLL__) || defined(__MSP430_HAS_FLLPLUS__)
cprintf(
"\nFLL: SCF QCTL %02x I0 %02x I1 %02x ; CTL0 %02x CTL1 %02x CTL2 %02x\n",
SCFQCTL, SCFI0, SCFI1, FLL_CTL0, FLL_CTL1,
#if defined(FLL_CTL2_)
FLL_CTL2
#else
~0
#endif
);
#endif
#if defined(__MSP430_HAS_UCS__) || defined(__MSP430_HAS_UCS_RF__)
"XT2CLK"
"REFOCLK"
#else
"XT1CLK"
#endif
);
cprintf(
"\nUCS RSEL %d DCO %d MOD %d:"
"\n CTL0 %04x CTL1 %04x CTL2 %04x CTL3 %04x"
"\n CTL4 %04x CTL5 %04x CTL6 %04x CTL7 %04x",
0x1F & (UCSCTL1 / DCORSEL0), 0x1F & (UCSCTL0 / DCO0), 0x1F & (UCSCTL0 / MOD0),
UCSCTL0, UCSCTL1, UCSCTL2, UCSCTL3,
UCSCTL4, UCSCTL5, UCSCTL6, UCSCTL7);
#endif
#if defined(__MSP430_HAS_CS__) || defined(__MSP430_HAS_CS_A__)
#if (BSP430_PERIPH_CS_IS_CS4 - 0)
cprintf(
"\nCS FR4 : FLLD %u FLLN %u"
"\n CTL0 %04x CTL1 %04x CTL2 %04x CTL3 %04x"
"\n CTL4 %04x CTL5 %04x CTL6 %04x CTL7 %04x"
"\n CTL8 %04x",
0x07 & (CSCTL2 / FLLD0), 0x3FF & CSCTL2,
CSCTL0, CSCTL1, CSCTL2, CSCTL3,
CSCTL4, CSCTL5, CSCTL6, CSCTL7,
CSCTL8);
#else
cprintf(
"\nCS %s : RSEL %d DCOFSEL %d:"
"\n CTL0 %04x CTL1 %04x CTL2 %04x CTL3 %04x"
"\n CTL4 %04x CTL5 %04x CTL6 %04x",
"FR57xx"
"FR58xx"
#else
"????"
#endif
, !!(DCORSEL & CSCTL1), 0x07 & (CSCTL1 / DCOFSEL0),
CSCTL0, CSCTL1, CSCTL2, CSCTL3,
CSCTL4, CSCTL5, CSCTL6);
#endif
#endif
#endif
#if (BSP430_CONSOLE - 0)
cputtext(
"\n\nClock signals exposed:\n ");
help = NULL;
#ifdef BSP430_PLATFORM_PERIPHERAL_HELP
#endif
if (NULL == help) {
help = "Go look at the data sheet and source, because nobody told me where they are";
}
cputtext(
"\nStatus register LPM bits: ");
#if defined(__MSP430_HAS_MSP430XV2_CPU__)
#else
#endif
#endif
#ifndef IDLE_LED
#if (BSP430_PLATFORM_EXP430FR4133 - 0)
#define IDLE_LED BSP430_LED_GREEN
#else
#define IDLE_LED BSP430_LED_RED
#endif
#endif
while (1) {
}
} else {
#if (BSP430_CONSOLE - 0)
cputtext(
"\nFailed to expose clock signals\n");
#endif
}
}
#ifndef configBSP430_PLATFORM_SPIN_FOR_JUMPER
#define configBSP430_PLATFORM_SPIN_FOR_JUMPER 1
#endif
#ifndef configBSP430_CONSOLE
#define configBSP430_CONSOLE 1
#endif
#define configBSP430_PLATFORM_PERIPHERAL_HELP 1
#ifndef configBSP430_PERIPH_EXPOSED_CLOCKS
#define configBSP430_PERIPH_EXPOSED_CLOCKS 1
#endif
#ifndef configBSP430_CORE_DISABLE_FLL
#define configBSP430_CORE_DISABLE_FLL 0
#endif
#ifndef BSP430_PLATFORM_BOOT_SMCLK_DIVIDING_SHIFT
#define BSP430_PLATFORM_BOOT_SMCLK_DIVIDING_SHIFT 1
#endif
#ifndef configBSP430_TIMER_CCACLK
#define configBSP430_TIMER_CCACLK 1
#endif
#ifndef BSP430_PLATFORM_BOOT_ACLK_SOURCE
#if defined(__MSP430_HAS_UCS__) || defined(__MSP430_HAS_UCS_RF__)
#define BSP430_PLATFORM_BOOT_ACLK_SOURCE eBSP430clockSRC_XT1CLK_OR_REFOCLK
#else
#define BSP430_PLATFORM_BOOT_ACLK_SOURCE eBSP430clockSRC_XT1CLK_OR_VLOCLK
#endif
#endif