at91sam9g20-ek-sdram.ini
上传用户:xukun0987
上传日期:2022-07-16
资源大小:216k
文件大小:6k
源码类别:

微处理器开发

开发平台:

C/C++

  1. // ----------------------------------------------------------------------------
  2. //         ATMEL Microcontroller Software Support 
  3. // ----------------------------------------------------------------------------
  4. // Copyright (c) 2008, Atmel Corporation
  5. //
  6. // All rights reserved.
  7. //
  8. // Redistribution and use in source and binary forms, with or without
  9. // modification, are permitted provided that the following conditions are met:
  10. //
  11. // - Redistributions of source code must retain the above copyright notice,
  12. // this list of conditions and the disclaimer below.
  13. //
  14. // Atmel's name may not be used to endorse or promote products derived from
  15. // this software without specific prior written permission.
  16. //
  17. // DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
  18. // IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
  19. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
  20. // DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,
  21. // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  22. // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
  23. // OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  24. // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  25. // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
  26. // EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  27. // ----------------------------------------------------------------------------
  28. //----------------------------------------------------------------------------
  29. //  File Name           : at91sam9260-ek-sdram.ini
  30. //  Object              : Generic Macro File for KEIL
  31. //----------------------------------------------------------------------------
  32. //----------------------------------------------------------------------------
  33. // MapRamAt0()
  34. // Function description: Maps RAM at 0.
  35. //----------------------------------------------------------------------------
  36. FUNC void MapRamAt0(){
  37.     printf ("Changing mapping: RAM mapped to 0 n");
  38.     _WDWORD(0xFFFFEF00,0x03);
  39. }
  40. //----------------------------------------------------------------------------
  41. // InitRSTC()
  42. // Function description
  43. //   Initializes the RSTC (Reset controller).
  44. //   This makes sense since the default is to not allow user resets, which makes it impossible to
  45. //   apply a second RESET via J-Link
  46. //----------------------------------------------------------------------------
  47. FUNC void InitRSTC() {
  48.     _WDWORD(0xA5000001,0xFFFFFD08);    // Allow user reset
  49. }
  50. //------------------------------------------------------------------------------
  51. // Configures the master clock at the best possible frequency.
  52. //------------------------------------------------------------------------------
  53. FUNC void ConfigureMck()
  54. {
  55.     __message "------------------------------- PLL @133MHz ----------------------------------";
  56.     // If clock is already configured, reset settings
  57.     if ((__readMemory32(0xFFFFFC30") & 0x3) != 0) {
  58.         // Disable interrupts and clocks
  59.         _WDWORD(0xFFFFFC64,0xFFFFFFFF); // PMC_IDR
  60.         _WDWORD(0xFFFFFC14,0xFFFFFFFF); // PMC_PCDR
  61.         _WDWORD(0xFFFFFC04,0xFFFFFFFE); // PMC_SCDR
  62.         // Switch to main oscillator
  63.         _WDWORD(0xFFFFFC30,0x00000001); // PMC_MCKR
  64.         _sleep_(10);
  65.         // Set default PLL settings
  66.         _WDWORD(0xFFFFFC28, 0x00003F00); // PMC_PLLAR
  67.         _WDWORD(0xFFFFFC2C,0x00003F00); // PMC_PLLBR
  68.         _sleep_(10);
  69.     }
  70.     // Enable mainosc
  71.     _WDWORD(0xFFFFFC20,0x00004001);
  72.     _sleep_(10);
  73.     // Switch to mainosc
  74.     _WDWORD(0xFFFFFC30,0x00000001);
  75.     _sleep_(10);
  76.     // Configure PLLA
  77.     _WDWORD(0xFFFFFC28,0x202A3F01);
  78.     _sleep_(10);
  79.     // Configure PLLB
  80.     _WDWORD(0xFFFFFC2C,0x10193F05);
  81.     _sleep_(10);
  82.     // Switch main oscillator + prescaler
  83.     _WDWORD(0xFFFFFC30,0x00001300);
  84.     _sleep_(10);
  85.     
  86.     // Switch to PLL + prescaler
  87.     _WDWORD(0xFFFFFC30,0x00001302);
  88.     _sleep_(10);
  89. }
  90. //------------------------------------------------------------------------------
  91. // Configures the SDRAM controller.
  92. //------------------------------------------------------------------------------
  93. FUNC void ConfigureSdram()
  94. {
  95.     // Enable EBI chip select
  96.     _WDWORD(0xFFFFEF1C,0x00000002);
  97.     
  98.     // Enable PC16-PC31 pins
  99.     _WDWORD(0xFFFFF870,0xFFFF0000);
  100.     _WDWORD(0xFFFFF874,0x00000000);
  101.     _WDWORD(0xFFFFF804,0xFFFF0000);
  102.     
  103.     // Load SDRAM configuration
  104.     _WDWORD(0xFFFFEA08,0x96338379);
  105.     // Initialize SDRAM
  106.     _WDWORD(0xFFFFEA00,0x00000001);
  107.     _WDWORD(0x20000000,0x00000000);
  108.     _WDWORD(0xFFFFEA00,0x00000002);
  109.     _WDWORD(0x20000000,0x00000000);
  110.     _WDWORD(0xFFFFEA00,0x00000004);
  111.     _WDWORD(0x20000000,0x00000000);
  112.     _WDWORD(0xFFFFEA00,0x00000004);
  113.     _WDWORD(0x20000000,0x00000000);
  114.     _WDWORD(0xFFFFEA00,0x00000004);
  115.     _WDWORD(0x20000000,0x00000000);
  116.     _WDWORD(0xFFFFEA00,0x00000004);
  117.     _WDWORD(0x20000000,0x00000000);
  118.     _WDWORD(0xFFFFEA00,0x00000004);
  119.     _WDWORD(0x20000000,0x00000000);
  120.     _WDWORD(0xFFFFEA00,0x00000004);
  121.     _WDWORD(0x20000000,0x00000000);
  122.     _WDWORD(0xFFFFEA00,0x00000004);
  123.     _WDWORD(0x20000000,0x00000000);
  124.     _WDWORD(0xFFFFEA00,0x00000004);
  125.     _WDWORD(0x20000000,0x00000000);
  126.     _WDWORD(0xFFFFEA00,0x00000003);
  127.     _WDWORD(0x20000000,0x00000000);
  128.     _WDWORD(0xFFFFEA00,0x00000000);
  129.     _WDWORD(0x20000000,0x00000000);
  130.     // Set refresh rate
  131.     _WDWORD(0xFFFFEA04,0x0000039D);
  132. }
  133. // Remap
  134.     MapRamAt0();
  135. //  Configure clock
  136.     ConfigureMck();
  137. // Configure the SDRAM
  138.     ConfigureSdram();
  139. // Enable user reset    
  140.     InitRSTC();  
  141.      
  142. LOAD at91sam9g20-sdram\at91sam9g20-sdram.axf INCREMENTAL
  143. PC = 0x20000000;
  144. g,main