LPC1788使用外扩SRAM,如何编写startup.s?
使用1788,keil环境。内部RAM不够用,想使用外部SRAM作为内存,内部SRAM不再使用,请问该如何修改startup.s?
the startup.s:
;/***********************************************************************
; * Project: LPC177x_8x startup code
; *
; * Description: LPC177x_8x startup code
; *
; * Copyright(C) 2011, NXP Semiconductor
; * All rights reserved.
; *
; ***********************************************************************
; * Software that is described herein is for illustrative purposes only
; * which provides customers with programming information regarding the
; * products. This software is supplied "AS IS" without any warranties.
; * NXP Semiconductors assumes no responsibility or liability for the
; * use of the software, conveys no license or title under any patent,
; * copyright, or mask work right to the product. NXP Semiconductors
; * reserves the right to make changes in the software without
; * notification. NXP Semiconductors also make no representation or
; * warranty that such application will be suitable for the specified
; * use without further testing or modification.
; **********************************************************************/
; <h> Stack Configuration
; <o> Stack Size (in Bytes) <0x0-0xFFFFFFFF:8>
; </h>
Stack_Size EQU 0x00000800
AREA STACK, NOINIT, READWRITE, ALIGN=3
Stack_Mem SPACE Stack_Size
__initial_sp
; <h> Heap Configuration
; <o>Heap Size (in Bytes) <0x0-0xFFFFFFFF:8>
; </h>
Heap_Size EQU 0x00000100
AREA HEAP, NOINIT, READWRITE, ALIGN=3
__heap_base
Heap_Mem SPACE Heap_Size
__heap_limit
PRESERVE8
THUMB
; Vector Table Mapped to Address 0 at Reset
AREA RESET, DATA, READONLY
EXPORT__Vectors
Sign_Value EQU 0x5A5A5A5A
__Vectors DCD __initial_sp ; 0 Top of Stack
DCD Reset_Handler ; 1 Reset Handler
DCD NMI_Handler ; 2 NMI Handler
DCD HardFault_Handler ; 3 Hard Fault Handler
DCD MemManage_Handler ; 4 MPU Fault Handler
DCD BusFault_Handler ; 5 Bus Fault Handler
DCD UsageFault_Handler ; 6 Usage Fault Handler
DCD Sign_Value ; 7 Reserved
DCD UnHandled_Vector ; 8 Reserved
DCD UnHandled_Vector ; 9 Reserved
DCD UnHandled_Vector ; 10 Reserved
DCD SVC_Handler ; 11 SVCall Handler
DCD DebugMon_Handler ; 12 Debug Monitor Handler
DCD UnHandled_Vector ; 13 Reserved
DCD PendSV_Handler ; 14 PendSV Handler
DCD SysTick_Handler ; 15 SysTick Handler
; External Interrupts
DCD WDT_IRQHandler ; 16 Watchdog Timer
DCD TIMER0_IRQHandler ; 17 Timer0
DCD TIMER1_IRQHandler ; 18 Timer1
DCD TIMER2_IRQHandler ; 19 Timer2
DCD TIMER3_IRQHandler ; 20 Timer3
DCD UART0_IRQHandler ; 21 UART0
DCD UART1_IRQHandler ; 22 UART1
DCD UART2_IRQHandler ; 23 UART2
DCD UART3_IRQHandler ; 24 UART3
DCD PWM1_IRQHandler ; 25 PWM1
DCD I2C0_IRQHandler ; 26 I2C0
DCD I2C1_IRQHandler ; 27 I2C1
DCD I2C2_IRQHandler ; 28 I2C2
DCD UnHandled_Vector ; 29 Reserved
DCD SSP0_IRQHandler ; 30 SSP0
DCD SSP1_IRQHandler ; 31 SSP1
DCD PLL0_IRQHandler ; 32 PLL0 Lock (Main PLL)
DCD RTC_IRQHandler ; 33 RTC
DCD EINT0_IRQHandler ; 34 External Interrupt 0
DCD EINT1_IRQHandler ; 35 External Interrupt 1
DCD EINT2_IRQHandler ; 36 External Interrupt 2
DCD EINT3_IRQHandler ; 37 External Interrupt 3
DCD ADC_IRQHandler ; 38 A/D Converter
DCD BOD_IRQHandler ; 39 Brown-Out Detect
DCD USB_IRQHandler ; 40 USB
DCD CAN_IRQHandler ; 41 CAN
DCD DMA_IRQHandler ; 42 General Purpose DMA
DCD I2S_IRQHandler ; 43 I2S
DCD ETH_IRQHandler ; 44 Ethernet
DCD SDIO_IRQHandler ; 45 SD/MMC card I/F
DCD MCPWM_IRQHandler ; 46 Motor Control PWM
DCD QEI_IRQHandler ; 47 QEI
DCD PLL1_IRQHandler ; 48 PLL1 Lock (USB PLL)
DCD USBActivity_IRQHandler ; 49 USB Activity interrupt to wakeup
DCD CANActivity_IRQHandler ; 50 CAN Activity interrupt to wakeup
DCD UART4_IRQHandler ; 51 UART4
DCD SSP2_IRQHandler ; 52 SSP2
DCD LCD_IRQHandler ; 53 LCD
DCD GPIO_IRQHandler ; 54 GPIO
DCD PWM0_IRQHandler ; 55 PWM0
DCD EEPROM_IRQHandler ; 56 EEPROM
; IF :LNOT::DEF:NO_CRP
; AREA |.ARM.__at_0x02FC|, CODE, READONLY
;CRP_Key DCD 0xFFFFFFFF
; ENDIF
AREA |.text|, CODE, READONLY
; Reset Handler
Reset_Handler PROC
EXPORTReset_Handler
IMPORT__main
IMPORTSystemInit
LDR R0, =SystemInit
BLX R0
LDR R0, =__main
BX R0
ENDP
; Dummy Exception Handlers (infinite loops which can be modified)
NMI_Handler PROC
EXPORTNMI_Handler
B .
ENDP
HardFault_Handler\
PROC
EXPORTHardFault_Handler
B .
ENDP
MemManage_Handler\
PROC
EXPORTMemManage_Handler
B .
ENDP
BusFault_Handler\
PROC
EXPORTBusFault_Handler
B .
ENDP
UsageFault_Handler\
PROC
EXPORTUsageFault_Handler
B .
ENDP
SVC_Handler PROC
EXPORTSVC_Handler
B .
ENDP
DebugMon_Handler\
PROC
EXPORTDebugMon_Handler
B .
ENDP
PendSV_HandlerPROC
EXPORTPendSV_Handler
B .
ENDP
SysTick_Handler PROC
EXPORTSysTick_Handler
B .
ENDP
UnHandled_Vector PROC
EXPORTUnHandled_Vector
B .
ENDP
Default_Handler PROC
EXPORTWDT_IRQHandler
EXPORTTIMER0_IRQHandler
EXPORTTIMER1_IRQHandler
EXPORTTIMER2_IRQHandler
EXPORTTIMER3_IRQHandler
EXPORTUART0_IRQHandler
EXPORTUART1_IRQHandler
EXPORTUART2_IRQHandler
EXPORTUART3_IRQHandler
EXPORTPWM1_IRQHandler
EXPORTI2C0_IRQHandler
EXPORTI2C1_IRQHandler
EXPORTI2C2_IRQHandler
EXPORTSPI_IRQHandler
EXPORTSSP0_IRQHandler
EXPORTSSP1_IRQHandler
EXPORTPLL0_IRQHandler
EXPORTRTC_IRQHandler
EXPORTEINT0_IRQHandler
EXPORTEINT1_IRQHandler
EXPORTEINT2_IRQHandler
EXPORTEINT3_IRQHandler
EXPORTADC_IRQHandler
EXPORTBOD_IRQHandler
EXPORTUSB_IRQHandler
EXPORTCAN_IRQHandler
EXPORTDMA_IRQHandler
EXPORTI2S_IRQHandler
EXPORTETH_IRQHandler
EXPORTSDIO_IRQHandler
EXPORTMCPWM_IRQHandler
EXPORTQEI_IRQHandler
EXPORTPLL1_IRQHandler
EXPORTUSBActivity_IRQHandler
EXPORTCANActivity_IRQHandler
EXPORTUART4_IRQHandler
EXPORTSSP2_IRQHandler
EXPORTLCD_IRQHandler
EXPORTGPIO_IRQHandler
EXPORTPWM0_IRQHandler
EXPORTEEPROM_IRQHandler
WDT_IRQHandler
TIMER0_IRQHandler
TIMER1_IRQHandler
TIMER2_IRQHandler
TIMER3_IRQHandler
UART0_IRQHandler
UART1_IRQHandler
UART2_IRQHandler
UART3_IRQHandler
PWM1_IRQHandler
I2C0_IRQHandler
I2C1_IRQHandler
I2C2_IRQHandler
SPI_IRQHandler
SSP0_IRQHandler
SSP1_IRQHandler
PLL0_IRQHandler
RTC_IRQHandler
EINT0_IRQHandler
EINT1_IRQHandler
EINT2_IRQHandler
EINT3_IRQHandler
ADC_IRQHandler
BOD_IRQHandler
USB_IRQHandler
CAN_IRQHandler
DMA_IRQHandler
I2S_IRQHandler
ETH_IRQHandler
SDIO_IRQHandler
MCPWM_IRQHandler
QEI_IRQHandler
PLL1_IRQHandler
USBActivity_IRQHandler
CANActivity_IRQHandler
UART4_IRQHandler
SSP2_IRQHandler
LCD_IRQHandler
GPIO_IRQHandler
PWM0_IRQHandler
EEPROM_IRQHandler
B .
ENDP
ALIGN
; User Initial Stack & Heap
IF :DEF:__MICROLIB
EXPORT__initial_sp
EXPORT__heap_base
EXPORT__heap_limit
ELSE
IMPORT__use_two_region_memory
EXPORT__user_initial_stackheap
__user_initial_stackheap
LDR R0, =Heap_Mem
LDR R1, =(Stack_Mem + Stack_Size)
LDR R2, = (Heap_Mem +Heap_Size)
LDR R3, = Stack_Mem
BX LR
ALIGN
ENDIF
END
the EMC_Init:
void EMC_GPIO_Init (void)
{
LPC_IOCON->P3_0 = (1<<0 | 0<<3 | 0<<5 | 1<<9); /* D0 @ P3.0 */
LPC_IOCON->P3_1 = (1<<0 | 0<<3 | 0<<5 | 1<<9); /* D1 @ P3.1 */
LPC_IOCON->P3_2 = (1<<0 | 0<<3 | 0<<5 | 1<<9); /* D2 @ P3.2 */
LPC_IOCON->P3_3 = (1<<0 | 0<<3 | 0<<5 | 1<<9); /* D3 @ P3.3 */
LPC_IOCON->P3_4 = (1<<0 | 0<<3 | 0<<5 | 1<<9); /* D4 @ P3.4 */
LPC_IOCON->P3_5 = (1<<0 | 0<<3 | 0<<5 | 1<<9); /* D5 @ P3.5 */
LPC_IOCON->P3_6 = (1<<0 | 0<<3 | 0<<5 | 1<<9); /* D6 @ P3.6 */
LPC_IOCON->P3_7 = (1<<0 | 0<<3 | 0<<5 | 1<<9); /* D7 @ P3.7 */
LPC_IOCON->P3_8 = (1<<0 | 0<<3 | 0<<5 | 1<<9); /* D8 @ P3.8 */
LPC_IOCON->P3_9 = (1<<0 | 0<<3 | 0<<5 | 1<<9); /* D9 @ P3.9 */
LPC_IOCON->P3_10 = (1<<0 | 0<<3 | 0<<5 | 1<<9); /* D10 @ P3.10 */
LPC_IOCON->P3_11 = (1<<0 | 0<<3 | 0<<5 | 1<<9); /* D11 @ P3.11 */
LPC_IOCON->P3_12 = (1<<0 | 0<<3 | 0<<5 | 1<<9); /* D12 @ P3.12 */
LPC_IOCON->P3_13 = (1<<0 | 0<<3 | 0<<5 | 1<<9); /* D13 @ P3.13 */
LPC_IOCON->P3_14 = (1<<0 | 0<<3 | 0<<5 | 1<<9); /* D14 @ P3.14 */
LPC_IOCON->P3_15 = (1<<0 | 0<<3 | 0<<5 | 1<<9); /* D15 @ P3.15 */
// LPC_IOCON->P4_0 = (1<<0 | 0<<3 | 0<<5 | 1<<9); /* A0 @ P4.0 */
LPC_IOCON->P4_1 = (1<<0 | 0<<3 | 0<<5 | 1<<9); /* A1 @ P4.1 */
LPC_IOCON->P4_2 = (1<<0 | 0<<3 | 0<<5 | 1<<9); /* A2 @ P4.2 */
LPC_IOCON->P4_3 = (1<<0 | 0<<3 | 0<<5 | 1<<9); /* A3 @ P4.3 */
LPC_IOCON->P4_4 = (1<<0 | 0<<3 | 0<<5 | 1<<9); /* A4 @ P4.4 */
LPC_IOCON->P4_5 = (1<<0 | 0<<3 | 0<<5 | 1<<9); /* A5 @ P4.5 */
LPC_IOCON->P4_6 = (1<<0 | 0<<3 | 0<<5 | 1<<9); /* A6 @ P4.6 */
LPC_IOCON->P4_7 = (1<<0 | 0<<3 | 0<<5 | 1<<9); /* A7 @ P4.7 */
LPC_IOCON->P4_8 = (1<<0 | 0<<3 | 0<<5 | 1<<9); /* A8 @ P4.8 */
LPC_IOCON->P4_9 = (1<<0 | 0<<3 | 0<<5 | 1<<9); /* A9 @ P4.9 */
LPC_IOCON->P4_10 = (1<<0 | 0<<3 | 0<<5 | 1<<9); /* A10 @ P4.10 */
LPC_IOCON->P4_11 = (1<<0 | 0<<3 | 0<<5 | 1<<9); /* A11 @ P4.11 */
LPC_IOCON->P4_12 = (1<<0 | 0<<3 | 0<<5 | 1<<9); /* A12 @ P4.12 */
LPC_IOCON->P4_13 = (1<<0 | 0<<3 | 0<<5 | 1<<9); /* A13 @ P4.13 */
LPC_IOCON->P4_14 = (1<<0 | 0<<3 | 0<<5 | 1<<9); /* A14 @ P4.14 */
LPC_IOCON->P4_15 = (1<<0 | 0<<3 | 0<<5 | 1<<9); /* A15 @ P4.15 */
LPC_IOCON->P4_16 = (1<<0 | 0<<3 | 0<<5 | 1<<9); /* A16 @ P4.16 */
LPC_IOCON->P4_17 = (1<<0 | 0<<3 | 0<<5 | 1<<9); /* A17 @ P4.17 */
LPC_IOCON->P4_18 = (1<<0 | 0<<3 | 0<<5 | 1<<9); /* A18 @ P4.18 */
LPC_IOCON->P4_25 = (1<<0 | 0<<3 | 0<<5 | 1<<9); /* WEN @ P4.25 */
LPC_IOCON->P4_24 = (1<<0 | 0<<3 | 0<<5 | 1<<9); /* OEN @ P4.24 */
LPC_IOCON->P4_26 = (1<<0 | 0<<3 | 0<<5 | 1<<9); /* BLSN @ P4.26 */
LPC_IOCON->P4_27 = (1<<0 | 0<<3 | 0<<5 | 1<<9); /* BLSN @ P4.27 */
LPC_IOCON->P4_31 = (1<<0 | 0<<3 | 0<<5 | 1<<9); /* M_CS @ P4.31 */
}
void SRAM_Init(void)
{
LPC_SC->PCONP |= 0x00000800; /* Enable External Memory Controller power/clock */
EMC_GPIO_Init();
Delay_Ms(200);
LPC_EMC->Control = 0x00000001; /*EMC enable*/
LPC_SC->EMCCLKSEL = 0x00000001; /* The EMC uses a clock at half the rate of the CPU*/
//LPC_SC->EMCCAL
LPC_EMC->Config= 0x00000000; /*little endian mode*/
Delay_Ms(200);
LPC_EMC->StaticConfig1 = 0x00000081;/*16bit */
Delay_Ms(200);
}
lz思路有问题{:sweat:}
内部也要用,外部只是补充 个人不改也能跑起来,除非程序一上电就需要sram 放在SystemInit的最后,直接用C写都可以啊
页:
[1]