Skip to content

lpc4322_hic: clock enhancements #925

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 12 commits into
base: develop
Choose a base branch
from
Prev Previous commit
Next Next commit
lpc43xx_hic,system: extract M setup as mdec_new
  • Loading branch information
Adrian Negreanu committed Feb 10, 2022
commit abcbeec42bf344877594c6d2225e05696166b683
31 changes: 18 additions & 13 deletions source/hic_hal/nxp/lpc4322/system_LPC43xx.c
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,23 @@ static unsigned pdec_new(unsigned psel)
return x;
}
}

#define PLL0_MSEL_MAX (1<<15)
/* multiplier: compute mdec from msel */
static unsigned mdec_new (unsigned msel)
{
unsigned x=0x4000, im;
switch (msel)
{
case 0: return 0xFFFFFFFF;
case 1: return 0x18003;
case 2: return 0x10003;
default:
for (im = msel; im <= PLL0_MSEL_MAX; im++)
x = (((x ^ (x >> 1)) & 1) << 14) | ((x >> 1) & 0xFFFF);
return x;
}
}
/******************************************************************************
* SetClock
******************************************************************************/
Expand Down Expand Up @@ -448,19 +465,7 @@ static void SetClock (void) {
LPC_CGU->PLL0USB_CTRL |= 1;

/* M divider */
x = 0x00004000;
switch (PLL0USB_M) {
case 0: x = 0xFFFFFFFF;
break;
case 1: x = 0x00018003;
break;
case 2: x = 0x00010003;
break;
default:
for (i = PLL0USB_M; i <= 0x8000; i++) {
x = (((x ^ (x >> 1)) & 1) << 14) | ((x >> 1) & 0x3FFF);
}
}
x = mdec_new(PLL0USB_M);

if (PLL0USB_M < 60) selp = (PLL0USB_M >> 1) + 1;
else selp = 31;
Expand Down
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy