I am using a clock component to set the frequency of a UDB based I2C component (external clock mode). The frequency setting of this clock component can change from design to design.
I also have a timeout in my code that is dependent on the bus clock frequency - I currently have a manually configured #define for a scaling value for the timeout ... which is ugly as changing the clock frequency in the top level design and missing changing the scaling value in the source code my timeout can fail at run time.
I was hoping that the the generated code for the clock component would include a #define indicating the configured clock frequency however this does not appear to be the case.
Is there a simple way to determine the configured frequency of a given clock at build time? The IDE cetainly has an awareness of this as it indicates the Actual Data Rate of the I2C module when I change the input clock frequency.
I would also be happy to read it at runtime too, the clock API seems only to have the following appropriate API calls:
uint16 Clock_2_GetDividerRegister(void) ;
uint8 Clock_2_GetSourceRegister(void) ;
Currently the clock is sourced from the IMO (XTAL) ... is there an easy way to determine the frequency of this clock even.