OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [freertos-6.1.1/] [Demo/] [ARM7_AT91SAM7X256_Eclipse/] [RTOSDemo/] [SrcAtmel/] [Cstartup_SAM7.c] - Blame information for rev 615

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 577 jeremybenn
//*----------------------------------------------------------------------------
2
//*         ATMEL Microcontroller Software Support  -  ROUSSET  -
3
//*----------------------------------------------------------------------------
4
//* The software is delivered "AS IS" without warranty or condition of any
5
//* kind, either express, implied or statutory. This includes without
6
//* limitation any warranty or condition with respect to merchantability or
7
//* fitness for any particular purpose, or against the infringements of
8
//* intellectual property rights of others.
9
//*----------------------------------------------------------------------------
10
//* File Name           : Cstartup_SAM7.c
11
//* Object              : Low level initializations written in C for IAR
12
//*                       tools
13
//* 1.0   08/Sep/04 JPP : Creation
14
//* 1.10  10/Sep/04 JPP : Update AT91C_CKGR_PLLCOUNT filed
15
//*----------------------------------------------------------------------------
16
 
17
 
18
// Include the board file description
19
#include "Board.h"
20
 
21
//*----------------------------------------------------------------------------
22
//* \fn    AT91F_LowLevelInit
23
//* \brief This function performs very low level HW initialization
24
//*        this function can be use a Stack, depending the compilation
25
//*        optimization mode
26
//*----------------------------------------------------------------------------
27
void AT91F_LowLevelInit( void);
28
void AT91F_LowLevelInit( void )
29
{
30
 AT91PS_PMC     pPMC = AT91C_BASE_PMC;
31
 
32
    //* Set Flash Waite sate
33
        //  Single Cycle Access at Up to 30 MHz, or 40
34
        //  if MCK = 47923200 I have 50 Cycle for 1 useconde ( flied MC_FMR->FMCN
35
            AT91C_BASE_MC->MC_FMR = ((AT91C_MC_FMCN)&(75 <<16)) | AT91C_MC_FWS_1FWS ;
36
 
37
    //* Watchdog Disable
38
        AT91C_BASE_WDTC->WDTC_WDMR= AT91C_WDTC_WDDIS;
39
 
40
        //* Set MCK at 47 923 200
41
    // 1 Enabling the Main Oscillator:
42
        // SCK = 1/32768 = 30.51 uSeconde
43
        // Start up time = 8 * 6 / SCK = 56 * 30.51 = 1,46484375 ms
44
       pPMC->PMC_MOR = ((( AT91C_CKGR_OSCOUNT & (0x06 <<8)) | AT91C_CKGR_MOSCEN ));
45
        // Wait the startup time
46
        while(!(pPMC->PMC_SR & AT91C_PMC_MOSCS));
47
        // 2 Checking the Main Oscillator Frequency (Optional)
48
        // 3 Setting PLL and divider:
49
                // - div by 5 Fin = 3,6864 =(18,432 / 5)
50
                // - Mul 25+1: Fout =   95,8464 =(3,6864 *26)
51
                // for 96 MHz the erroe is 0.16%
52
                //eld out NOT USED = 0 Fi
53
       pPMC->PMC_PLLR = ((AT91C_CKGR_DIV & 5) |
54
                         (AT91C_CKGR_PLLCOUNT & (28<<8)) |
55
                         (AT91C_CKGR_MUL & (25<<16)));
56
 
57
        // Wait the startup time
58
        while(!(pPMC->PMC_SR & AT91C_PMC_LOCK));
59
        // 4. Selection of Master Clock and Processor Clock
60
        // select the PLL clock divided by 2
61
       pPMC->PMC_MCKR = AT91C_PMC_PRES_CLK_2 ;
62
        while(!(pPMC->PMC_SR & AT91C_PMC_MCKRDY));
63
 
64
        pPMC->PMC_MCKR |= AT91C_PMC_CSS_PLL_CLK ;
65
        while(!(pPMC->PMC_SR & AT91C_PMC_MCKRDY));
66
}
67
 
68
 
69
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.