3.2.12 DIAG_FREQM
The DIAG_FREQM module is designed to verify the correct functionality of the Frequency Measurement (FREQM) through a set of C function calls.
Note: This module contains routines which sets the main clock at
48 MHz. The user would need to call DIAG_OSCCTRL_Initialize to restore the
clock.
The DIAG_FREQM software test API is mapped to the following safety mechanisms:
| Function | Diagnostic Mechanism | Use Case | Elasped Timer (μs) ~ |
|---|---|---|---|
| DIAG_FREQM_ClockCalibration() | FREQM_CLOCK_CALIBRATION | POST / OnDemand | 54.14 |
| DIAG_FREQM_SFRReset() | SFR_RESET_STATE | POST | 16.04 |
| DIAG_FREQM_SFRWriteRead() | SFR_WRITE_READ | POST / OnDemand | 37.22 |
Configuring the Diagnostic
FREQM Safe-Plib can be configured as illustrated to supported to support all diagnostics:

Run-time Pre-requisites
DIAG_FREQM_SFRRead should be executed before DIAG_FREQM_SFRWriteRead
DIAG_GCLK_Initialize should be executed to initialize the clock
DIAG_FREQM_MeasurementStart should be executed to start the measurement
Using the Diagnostic
#include "definitions.h"
DIAG_TEST_STATUS DIAG_FREQM_SFRPost()
{
DIAG_TEST_STATUS result[NO_OF_FREQM_SFRPOST_TESTS];
DIAG_TEST_STATUS test_status = DIAG_TEST_FAILED;
int i;
result[0] = DIAG_FREQM_SFRReset(NULL,0,false);
result[1] = DIAG_FREQM_SFRWriteRead(NULL,0,false);
// DO ADDITIONAL POST TESTS HERE
for(i=0; i < NO_OF_FREQM_SFRPOST_TESTS; i++)
{
if (result[i] != DIAG_TEST_PASSED)
{
test_status = result[i];
break;
}
else
{
test_status = DIAG_TEST_PASSED;
}
}
return test_status;
}
DIAG_TEST_STATUS DIAG_FREQM_Post()
{
return DIAG_FREQM_Calibration(DIAG_GCLK1, DIAG_GCLK2);
}
void DIAG_FREQM_Post_Pre()
{
// Initialize the dependent peripherals required to run the GCLK test.
DIAG_GCLK_Initialize(DIAG_GCLK1, (uint16_t)(48000000/6000000));
// Start the frequency measurement.
DIAG_FREQM_MeasurementStart();
}
