Change system clock frequency to 150MHZ

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Change system clock frequency to 150MHZ

507 Views
timmermans
Contributor I

I need my system clock to run on 150 MHz. But I also need to read&write to Flash. 
To achieve this I wanted to change the clock from 150 MHz to 75 MHz and after the Flash operation bump the speed back up to 150 MHz. 

But I am not sure how to do this. 
I wanted to do is in the following way:


void System::decreaseMainClockSpeed()
{
CLOCK_SetClkDiv(kCLOCK_DivAhbClk, 2U, false);
POWER_SetVoltageForFreq(75000000);
SystemCoreClock = 75000000;
}

void System::resetMainClockToOriginalSpeed()
{
POWER_SetVoltageForFreq(150000000);
CLOCK_SetClkDiv(kCLOCK_DivAhbClk, 1U, false);
CLOCK_GetFreq(kCLOCK_BusClk);
SystemCoreClock = 150000000;
}

 

The decreaseMainClockSpeed function works like it should. But when I call the resetMainClockToOriginalSpeed everything breaks after the CLOCK_SetClkDiv(kCLOCK_DivAhbClk, 1U, false); function.

Can someone help me?

Labels (1)
0 Kudos
1 Reply

495 Views
Pavel_Hernandez
NXP TechSupport
NXP TechSupport

Hello, 

I recommend the use of the MCU config tool, try to change the frequency and evaluate what changes were made in the code then implement them in your application.

0 Kudos