Hello, I'm having some troubles changing the clock speed of an iMX RT1060 in real time. I tried following the TEMPMON SDK example to produce a similar result. However, when I call `CLOCK_SetDiv(kCLOCK_AhbDiv, 1);` it seems to cause the board to slow down, then reset. This is not a watchdog or a temperature panic reset from my testing. Here is the code that is the most relevant. Please let me know if you have any questions.
void
temp_warnings()
{
int temperature = RT106X_SENSOR_Read(false);
if (tempisr_high == true &&
(temperature - tempmon_high_alarm_temp_celsius > 0)) {
printf("Warning: CPU Temperature has exceeded %dC!\r\n"
"Throttling the CPU clock speed until temperature lowers.\r\n",
tempmon_high_alarm_temp_celsius);
CLOCK_SetDiv(kCLOCK_AhbDiv, 1);
coreFrequency = CLOCK_GetFreq(kCLOCK_AhbClk);
PRINTF("The chip core frequency is %d Hz. \r\n", coreFrequency);
tempisr_high = false;
} else if (tempisr_high == false &&
(temperature - tempmon_low_alarm_temp_celsius < 0)) {
printf("CPU Temperature is below %dC.\r\n"
"CPU clock speed returning to normal.\r\n",
tempmon_low_alarm_temp_celsius);
CLOCK_SetDiv(kCLOCK_AhbDiv, 0);
coreFrequency = CLOCK_GetFreq(kCLOCK_AhbClk);
PRINTF("The chip core frequency is %d Hz. \r\n", coreFrequency);
tempisr_high = true;
}
}