One of my board had low voltage issue and it seems caused G400 running extra slow. The low voltage issue is resolved but I want to add check in firmware should this happen in future we can display it as an error.
I read the Atmel-11055F-ATARM-SAM9X35-Datasheet_31-Aug-15, on page 195 it lists the register CKGR_MCFR should contain main clock cycle count so I can easily calculate it with the formula:
fMAINCK = (MAINF * fSLCK) / 16 (Where frequency is in MHz)
This is my code to get the register value:
var CKGR_MCFR = 0xFFFFFC24;
var reg = new Register(CKGR_MCFR);
var va = reg.Value;
var reg1 = new Register(CKGR_MCFR);
var va2 = reg1.Value;
Both va & va2 are 0x118FC. The bit 16 is 1 which indicate MAINF is reliable. The MAINF = 0x18FC = 6396.
6396 * 0.032768 / 16 = 13.099008MHz
The result is far off from the G400 actual running frequency which should be 400MHz. I also checked the crystal on G400 board is 12.000MHz so the 13.09MHz couldn’t be referring to the crystal frequency.
I am little puzzled how is the main clock frequency is calculated.