lpc176x: Do not modify PCLKSELx at runtime

The lpc176x has an errata that could cause updates to PCLKSELx to not
take effect.  Rework the code to use the default peripheral clock
speed (25Mhz or 30Mhz) so that this register does not need to be
updated at runtime.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
Kevin O'Connor 2021-03-24 19:49:08 -04:00
parent 6cab7bcfcb
commit ae89a65956
1 changed files with 1 additions and 8 deletions

View File

@ -49,20 +49,13 @@ void
enable_pclock(uint32_t pclk)
{
LPC_SC->PCONP |= 1<<pclk;
if (pclk < 16) {
uint32_t shift = pclk * 2;
LPC_SC->PCLKSEL0 = (LPC_SC->PCLKSEL0 & ~(0x3<<shift)) | (0x1<<shift);
} else {
uint32_t shift = (pclk - 16) * 2;
LPC_SC->PCLKSEL1 = (LPC_SC->PCLKSEL1 & ~(0x3<<shift)) | (0x1<<shift);
}
}
// Return the frequency of the given peripheral clock
uint32_t
get_pclock_frequency(uint32_t pclk)
{
return CONFIG_CLOCK_FREQ;
return CONFIG_CLOCK_FREQ / 4;
}
// Main entry point - called from armcm_boot.c:ResetHandler()