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 SELI setup as anadeci_new
  • Loading branch information
Adrian Negreanu committed Feb 10, 2022
commit dd0bb84154e056b2c17dd879bae0e7e84f2ac6c6
24 changes: 17 additions & 7 deletions source/hic_hal/nxp/lpc4322/system_LPC43xx.c
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,22 @@ static unsigned mdec_new (unsigned msel)
return x;
}
}

/* bandwidth: compute seli from msel */
unsigned anadeci_new(unsigned msel)
{
unsigned tmp;
if (msel > 16384) return 1;
if (msel > 8192) return 2;
if (msel > 2048) return 4;
if (msel >= 501) return 8;
if (msel >= 60)
{
tmp=1024/(msel+9);
return ( 1024 == ( tmp*(msel+9)) ) == 0 ? tmp*4 : (tmp+1)*4 ;
}
return (msel & 0x3c) + 4;
}
/******************************************************************************
* SetClock
******************************************************************************/
Expand Down Expand Up @@ -469,13 +485,7 @@ static void SetClock (void) {

if (PLL0USB_M < 60) selp = (PLL0USB_M >> 1) + 1;
else selp = 31;

if (PLL0USB_M > 16384) seli = 1;
else if (PLL0USB_M > 8192) seli = 2;
else if (PLL0USB_M > 2048) seli = 4;
else if (PLL0USB_M >= 501) seli = 8;
else if (PLL0USB_M >= 60) seli = 4 * (1024 / (PLL0USB_M + 9));
else seli = (PLL0USB_M & 0x3C) + 4;
seli = anadeci_new(PLL0USB_M);
LPC_CGU->PLL0USB_MDIV = (selp << 17) |
(seli << 22) |
(x << 0);
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