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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [freertos-6.1.1/] [Demo/] [ARM7_AT91SAM7S64_IAR/] [SrcIAR/] [Cstartup_SAM7.c] - Blame information for rev 603

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
//* Creation            : 12/Jun/04
14
//*
15
//*----------------------------------------------------------------------------
16
 
17
 
18
// Include the board file description
19
#include "Board.h"
20
 
21
// The following functions must be write in ARM mode this function called directly
22
// by exception vector
23
extern void AT91F_Spurious_handler(void);
24
extern void AT91F_Default_IRQ_handler(void);
25
extern void AT91F_Default_FIQ_handler(void);
26
 
27
//*----------------------------------------------------------------------------
28
//* \fn    AT91F_LowLevelInit
29
//* \brief This function performs very low level HW initialization
30
//*        this function can be use a Stack, depending the compilation
31
//*        optimization mode
32
//*----------------------------------------------------------------------------
33
void AT91F_LowLevelInit( void );
34
void AT91F_LowLevelInit( void) @ "ICODE"
35
{
36
 int            i;
37
 AT91PS_PMC     pPMC = AT91C_BASE_PMC;
38
    //* Set Flash Waite sate
39
        //  Single Cycle Access at Up to 30 MHz, or 40
40
        //  if MCK = 47923200 I have 50 Cycle for 1 useconde ( flied MC_FMR->FMCN
41
            AT91C_BASE_MC->MC_FMR = ((AT91C_MC_FMCN)&(50 <<16)) | AT91C_MC_FWS_1FWS ;
42
 
43
    //* Watchdog Disable
44
        AT91C_BASE_WDTC->WDTC_WDMR= AT91C_SYSC_WDDIS;
45
 
46
        //* Set MCK at 47 923 200
47
    // 1 Enabling the Main Oscillator:
48
        // SCK = 1/32768 = 30.51 uSeconde
49
        // Start up time = 8 * 6 / SCK = 56 * 30.51 = 1,46484375 ms
50
       pPMC->PMC_MOR = (( AT91C_CKGR_OSCOUNT & (0x06 <<8) | AT91C_CKGR_MOSCEN ));
51
        // Wait the startup time
52
        while(!(pPMC->PMC_SR & AT91C_PMC_MOSCS));
53
        // 2 Checking the Main Oscillator Frequency (Optional)
54
        // 3 Setting PLL and divider:
55
                // - div by 5 Fin = 3,6864 =(18,432 / 5)
56
                // - Mul 25+1: Fout =   95,8464 =(3,6864 *26)
57
                // for 96 MHz the erroe is 0.16%
58
                // Field out NOT USED = 0
59
                // PLLCOUNT pll startup time esrtimate at : 0.844 ms
60
                // PLLCOUNT 28 = 0.000844 /(1/32768)
61
       pPMC->PMC_PLLR = ((AT91C_CKGR_DIV & 0x05) |
62
                         (AT91C_CKGR_PLLCOUNT & (28<<8)) |
63
                         (AT91C_CKGR_MUL & (25<<16)));
64
 
65
        // Wait the startup time
66
        while(!(pPMC->PMC_SR & AT91C_PMC_LOCK));
67
        // 4. Selection of Master Clock and Processor Clock
68
        // select the PLL clock divided by 2
69
            pPMC->PMC_MCKR = AT91C_PMC_CSS_PLL_CLK | AT91C_PMC_PRES_CLK_2 ;
70
 
71
        // Enable User Reset and set its minimal assertion to 960 us
72
        AT91C_BASE_RSTC->RSTC_RMR = AT91C_SYSC_URSTEN | (0x4<<8) | (unsigned int) (0xA5<<24);
73
 
74
 
75
        // Set up the default interrupts handler vectors
76
        AT91C_BASE_AIC->AIC_SVR[0] = (int) AT91F_Default_FIQ_handler ;
77
        for (i=1;i < 31; i++)
78
        {
79
            AT91C_BASE_AIC->AIC_SVR[i] = (int) AT91F_Default_IRQ_handler ;
80
        }
81
        AT91C_BASE_AIC->AIC_SPU  = (int) AT91F_Spurious_handler ;
82
 
83
}
84
 

powered by: WebSVN 2.1.0

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