Changeset 47dbc76 in rtems


Ignore:
Timestamp:
Jun 3, 2006, 3:20:15 AM (14 years ago)
Author:
Jay Monkman <jtm@…>
Branches:
4.10, 4.11, 4.8, 4.9, 5, master
Children:
20e266ca
Parents:
9cdfb0e
Message:

2006-06-02 Jay Monkman <jtm@…>

  • startup/bspstart.c: Fixed PLL calculations.
Location:
c/src/lib/libbsp/arm/csb336
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • c/src/lib/libbsp/arm/csb336/ChangeLog

    r9cdfb0e r47dbc76  
    1 2006-06-02      Jay Monkman
     12006-06-02      Jay Monkman <jtm@lopingdog.com>
     2
     3        * Makefile.am, console/uart.c, startup/exit.c:  Changed UART
     4          driver to be interrupt driven, added support for both UARTs.
     5
     6
     72006-06-02      Jay Monkman <jtm@lopingdog.com>
    28
    39        * network/network.c: Changed interrupt handling
  • c/src/lib/libbsp/arm/csb336/startup/bspstart.c

    r9cdfb0e r47dbc76  
    8787/*                                                                        */
    8888/**************************************************************************/
     89void mmu_set_cpu_async_mode(void);
    8990void bsp_start_default( void )
    9091{
     92    int i;
     93
     94    /* Set the MCU prescaler to divide by 1 */
     95    MC9328MXL_PLL_CSCR &= ~MC9328MXL_PLL_CSCR_PRESC;
     96
     97    /* Enable the MCU PLL */
     98    MC9328MXL_PLL_CSCR |= MC9328MXL_PLL_CSCR_MPEN;
     99
     100    /* Delay to allow time for PLL to get going */
     101    for (i = 0; i < 100; i++) {
     102        asm volatile ("nop\n");
     103    }
     104
     105    /* Set the CPU to asynchrous clock mode, so it uses its fastest clock */
     106    mmu_set_cpu_async_mode();
    91107
    92108    /* disable interrupts */
     
    154170int get_perclk1_freq(void)
    155171{
    156     int fin;
    157     int fpll;
    158     int pd;
    159     int mfd;
    160     int mfi;
    161     int mfn;
     172    unsigned int fin;
     173    unsigned int fpll;
     174    unsigned int pd;
     175    unsigned int mfd;
     176    unsigned int mfi;
     177    unsigned int mfn;
    162178    uint32_t reg;
    163179    int perclk1;
     
    188204    printk("mfi = %d\n", mfi);
    189205    printk("mfn = %d\n", mfn);
    190     printk("(fin * mfi) / (pd + 1) = %d\n", (fin * mfi) / (pd + 1));
    191     printk("(fin * mfn) / ((pd + 1) * (mfd + 1)) = %d\n",
    192            (fin * mfn) / ((pd + 1) * (mfd + 1)));
     206    printk("rounded (fin * mfi) / (pd + 1) = %d\n", (fin * mfi) / (pd + 1));
     207    printk("rounded (fin * mfn) / ((pd + 1) * (mfd + 1)) = %d\n",
     208           ((long long)fin * mfn) / ((pd + 1) * (mfd + 1)));
    193209#endif
    194210
    195     fpll = 2 * ( ((fin * mfi) / (pd + 1)) +
    196                  ((fin * mfn) / ((pd + 1) * (mfd + 1))) );
     211    fpll = 2 * ( ((fin * mfi  + (pd + 1) / 2) / (pd + 1)) +
     212                 (((long long)fin * mfn + ((pd + 1) * (mfd + 1)) / 2) /
     213                 ((pd + 1) * (mfd + 1))) );
    197214
    198215    /* calculate the output of the PERCLK1 divider */
Note: See TracChangeset for help on using the changeset viewer.