File tree Expand file tree Collapse file tree 1 file changed +18
-13
lines changed
source/hic_hal/nxp/lpc4322 Expand file tree Collapse file tree 1 file changed +18
-13
lines changed Original file line number Diff line number Diff line change @@ -352,6 +352,23 @@ static unsigned pdec_new(unsigned psel)
352
352
return x ;
353
353
}
354
354
}
355
+
356
+ #define PLL0_MSEL_MAX (1<<15)
357
+ /* multiplier: compute mdec from msel */
358
+ static unsigned mdec_new (unsigned msel )
359
+ {
360
+ unsigned x = 0x4000 , im ;
361
+ switch (msel )
362
+ {
363
+ case 0 : return 0xFFFFFFFF ;
364
+ case 1 : return 0x18003 ;
365
+ case 2 : return 0x10003 ;
366
+ default :
367
+ for (im = msel ; im <= PLL0_MSEL_MAX ; im ++ )
368
+ x = (((x ^ (x >> 1 )) & 1 ) << 14 ) | ((x >> 1 ) & 0xFFFF );
369
+ return x ;
370
+ }
371
+ }
355
372
/******************************************************************************
356
373
* SetClock
357
374
******************************************************************************/
@@ -448,19 +465,7 @@ static void SetClock (void) {
448
465
LPC_CGU -> PLL0USB_CTRL |= 1 ;
449
466
450
467
/* M divider */
451
- x = 0x00004000 ;
452
- switch (PLL0USB_M ) {
453
- case 0 : x = 0xFFFFFFFF ;
454
- break ;
455
- case 1 : x = 0x00018003 ;
456
- break ;
457
- case 2 : x = 0x00010003 ;
458
- break ;
459
- default :
460
- for (i = PLL0USB_M ; i <= 0x8000 ; i ++ ) {
461
- x = (((x ^ (x >> 1 )) & 1 ) << 14 ) | ((x >> 1 ) & 0x3FFF );
462
- }
463
- }
468
+ x = mdec_new (PLL0USB_M );
464
469
465
470
if (PLL0USB_M < 60 ) selp = (PLL0USB_M >> 1 ) + 1 ;
466
471
else selp = 31 ;
You can’t perform that action at this time.
0 commit comments