问题背景 图一:Debug错误 问题分析- void ResetISR(void) {
- // Disable interrupts
- __asm volatile ("cpsid i");
- FLEXRAM->TCM_CTRL = 4;
- IOMUXC_GPR->GPR17 = 0x00005555; //FlexRAM全部配置层OCRAM
- IOMUXC_GPR->GPR16 |= 0x4;
- IOMUXC_GPR->GPR16 &= ~(0x3); //禁用ITCM,DTCM
- IOMUXC_GPR->GPR14 = ((0<<20) | (0<<16)) ;
- __asm volatile ("MSR MSP, %0" : : "r" (&_vStackTop) : );
- ~~~~~~~
- ~~~~~~~
- ~~~~~~~
- }
复制代码 问题解决图二 iMXRT1020_QSPI工程 RT1024相较于RT1020最大的不同就是,QSPI flash集成在RT1024的封装里面,对外就与内置的Flash一样。
其中对应的FlexSPI模块的连接线如下图所示,所以我们除了需要MemoryDevice连接到OCRAM区域执行外,还需要修改FlexSPI模块引脚的初始化以与图三相符,具体过程如下: 图三 FlexSPI模块连接线 - 修改iMXRT1020_QSPI工程的FlashDriver_32Kbuffer.ld链接文件,具体如下
- /*
- * Linker script for NXP LPC546xx SPIFI Flash Driver (Messaged)
- */
-
- MEMORY
- {
- /*SRAM (rwx) : ORIGIN = 0x20000000, LENGTH = (64 * 1024)*/
- SRAM (rwx) : ORIGIN = 0x20200000, LENGTH = (64 * 1024) /*OCRAM的前64KB区域/*
- }
- /* stack size : multiple of 8*/
- __stack_size = (4 * 1024);
- /* flash image buffer size : multiple of page size*/
- __cache_size = (32 * 1024);
- ~~~~~~~~~~
- ~~~~~~~~~~
- }
复制代码
- 修改iMXRT1020_QSPI工程中的pin_mux.c文件内的BOARD_InitPins函数,代码如下:
- /* FUNCTION ************************************************************************************************************
- *
- * Function Name : BOARD_InitPins
- * Description : Configures pin routing and optionally pin electrical features.
- *
- * END ****************************************************************************************************************/
- void BOARD_InitPins(void) {
- CLOCK_EnableClock(kCLOCK_Iomuxc); /* iomuxc clock (iomuxc_clk_enable): 0x03u */
- IOMUXC_SetPinMux(
- IOMUXC_GPIO_AD_B0_06_LPUART1_TX, /* GPIO_AD_B0_06 is configured as LPUART1_TX */
- 0U); /* Software Input On Field: Input Path is determined by functionality */
- IOMUXC_SetPinMux(
- IOMUXC_GPIO_AD_B0_07_LPUART1_RX, /* GPIO_AD_B0_07 is configured as LPUART1_RX */
- 0U); /* Software Input On Field: Input Path is determined by functionality */
- IOMUXC_SetPinMux(
- IOMUXC_GPIO_SD_B1_05_FLEXSPI_A_DQS, /* GPIO_SD_B1_05 is configured as FLEXSPI_A_DQS */
- 1U); /* Software Input On Field: Force input path of pad GPIO_SD_B1_05 */
- // IOMUXC_SetPinMux(
- // IOMUXC_GPIO_SD_B1_06_FLEXSPI_A_DATA03, /* GPIO_SD_B1_06 is configured as FLEXSPI_A_DATA03 */
- // 1U); /* Software Input On Field: Force input path of pad GPIO_SD_B1_06 */
- // IOMUXC_SetPinMux(
- // IOMUXC_GPIO_SD_B1_07_FLEXSPI_A_SCLK, /* GPIO_SD_B1_07 is configured as FLEXSPI_A_SCLK */
- // 1U); /* Software Input On Field: Force input path of pad GPIO_SD_B1_07 */
- // IOMUXC_SetPinMux(
- // IOMUXC_GPIO_SD_B1_08_FLEXSPI_A_DATA00, /* GPIO_SD_B1_08 is configured as FLEXSPI_A_DATA00 */
- // 1U); /* Software Input On Field: Force input path of pad GPIO_SD_B1_08 */
- // IOMUXC_SetPinMux(
- // IOMUXC_GPIO_SD_B1_09_FLEXSPI_A_DATA02, /* GPIO_SD_B1_09 is configured as FLEXSPI_A_DATA02 */
- // 1U); /* Software Input On Field: Force input path of pad GPIO_SD_B1_09 */
- // IOMUXC_SetPinMux(
- // IOMUXC_GPIO_SD_B1_10_FLEXSPI_A_DATA01, /* GPIO_SD_B1_10 is configured as FLEXSPI_A_DATA01 */
- // 1U); /* Software Input On Field: Force input path of pad GPIO_SD_B1_10 */
- // IOMUXC_SetPinMux(
- // IOMUXC_GPIO_SD_B1_11_FLEXSPI_A_SS0_B, /* GPIO_SD_B1_11 is configured as FLEXSPI_A_SS0_B */
- // 1U); /* Software Input On Field: Force input path of pad GPIO_SD_B1_11 */
- IOMUXC_SetPinMux(
- IOMUXC_GPIO_AD_B1_00_FLEXSPI_A_DATA03, /* GPIO_AD_B1_00 is configured as FLEXSPI_A_DATA03 */
- 1U); /* Software Input On Field: Force input path of pad GPIO_AD_B1_00 */
- IOMUXC_SetPinMux(
- IOMUXC_GPIO_AD_B1_01_FLEXSPI_A_SCLK, /* GPIO_AD_B1_01 is configured as FLEXSPI_A_SCLK */
- 1U); /* Software Input On Field: Force input path of pad GPIO_AD_B1_01 */
- IOMUXC_SetPinMux(
- IOMUXC_GPIO_AD_B1_02_FLEXSPI_A_DATA00, /* GPIO_AD_B1_02 is configured as FLEXSPI_A_DATA00 */
- 1U); /* Software Input On Field: Force input path of pad GPIO_AD_B1_02 */
- IOMUXC_SetPinMux(
- IOMUXC_GPIO_AD_B1_03_FLEXSPI_A_DATA02, /* GPIO_AD_B1_03 is configured as FLEXSPI_A_DATA02 */
- 1U); /* Software Input On Field: Force input path of pad GPIO_AD_B1_03 */
- IOMUXC_SetPinMux(
- IOMUXC_GPIO_AD_B1_04_FLEXSPI_A_DATA01, /* GPIO_AD_B1_04 is configured as FLEXSPI_A_DATA01 */
- 1U); /* Software Input On Field: Force input path of pad GPIO_AD_B1_04 */
- IOMUXC_SetPinMux(
- IOMUXC_GPIO_AD_B1_05_FLEXSPI_A_SS0_B, /* GPIO_AD_B1_05 is configured as FLEXSPI_A_SS0_B */
- 1U); /* Software Input On Field: Force input path of pad GPIO_AD_B1_05 */
- IOMUXC_SetPinConfig(
- IOMUXC_GPIO_AD_B0_06_LPUART1_TX, /* GPIO_AD_B0_06 PAD functional properties : */
- 0x10B0u); /* Slew Rate Field: Slow Slew Rate
- Drive Strength Field: R0/6
- Speed Field: medium(100MHz)
- Open Drain Enable Field: Open Drain Disabled
- Pull / Keep Enable Field: Pull/Keeper Enabled
- Pull / Keep Select Field: Keeper
- Pull Up / Down Config. Field: 100K Ohm Pull Down
- Hyst. Enable Field: Hysteresis Disabled */
- IOMUXC_SetPinConfig(
- IOMUXC_GPIO_AD_B0_07_LPUART1_RX, /* GPIO_AD_B0_07 PAD functional properties : */
- 0x10B0u); /* Slew Rate Field: Slow Slew Rate
- Drive Strength Field: R0/6
- Speed Field: medium(100MHz)
- Open Drain Enable Field: Open Drain Disabled
- Pull / Keep Enable Field: Pull/Keeper Enabled
- Pull / Keep Select Field: Keeper
- Pull Up / Down Config. Field: 100K Ohm Pull Down
- Hyst. Enable Field: Hysteresis Disabled */
- IOMUXC_SetPinConfig(
- IOMUXC_GPIO_SD_B1_05_FLEXSPI_A_DQS, /* GPIO_SD_B1_05 PAD functional properties : */
- 0x10F1u); /* Slew Rate Field: Fast Slew Rate
- Drive Strength Field: R0/6
- Speed Field: max(200MHz)
- Open Drain Enable Field: Open Drain Disabled
- Pull / Keep Enable Field: Pull/Keeper Enabled
- Pull / Keep Select Field: Keeper
- Pull Up / Down Config. Field: 100K Ohm Pull Down
- Hyst. Enable Field: Hysteresis Disabled */
- IOMUXC_SetPinConfig(
- IOMUXC_GPIO_SD_B1_06_FLEXSPI_A_DATA03, /* GPIO_SD_B1_06 PAD functional properties : */
- 0x10F1u); /* Slew Rate Field: Fast Slew Rate
- Drive Strength Field: R0/6
- Speed Field: max(200MHz)
- Open Drain Enable Field: Open Drain Disabled
- Pull / Keep Enable Field: Pull/Keeper Enabled
- Pull / Keep Select Field: Keeper
- Pull Up / Down Config. Field: 100K Ohm Pull Down
- Hyst. Enable Field: Hysteresis Disabled */
- IOMUXC_SetPinConfig(
- IOMUXC_GPIO_SD_B1_07_FLEXSPI_A_SCLK, /* GPIO_SD_B1_07 PAD functional properties : */
- 0x10F1u); /* Slew Rate Field: Fast Slew Rate
- Drive Strength Field: R0/6
- Speed Field: max(200MHz)
- Open Drain Enable Field: Open Drain Disabled
- Pull / Keep Enable Field: Pull/Keeper Enabled
- Pull / Keep Select Field: Keeper
- Pull Up / Down Config. Field: 100K Ohm Pull Down
- Hyst. Enable Field: Hysteresis Disabled */
- IOMUXC_SetPinConfig(
- IOMUXC_GPIO_SD_B1_08_FLEXSPI_A_DATA00, /* GPIO_SD_B1_08 PAD functional properties : */
- 0x10F1u); /* Slew Rate Field: Fast Slew Rate
- Drive Strength Field: R0/6
- Speed Field: max(200MHz)
- Open Drain Enable Field: Open Drain Disabled
- Pull / Keep Enable Field: Pull/Keeper Enabled
- Pull / Keep Select Field: Keeper
- Pull Up / Down Config. Field: 100K Ohm Pull Down
- Hyst. Enable Field: Hysteresis Disabled */
- IOMUXC_SetPinConfig(
- IOMUXC_GPIO_SD_B1_09_FLEXSPI_A_DATA02, /* GPIO_SD_B1_09 PAD functional properties : */
- 0x10F1u); /* Slew Rate Field: Fast Slew Rate
- Drive Strength Field: R0/6
- Speed Field: max(200MHz)
- Open Drain Enable Field: Open Drain Disabled
- Pull / Keep Enable Field: Pull/Keeper Enabled
- Pull / Keep Select Field: Keeper
- Pull Up / Down Config. Field: 100K Ohm Pull Down
- Hyst. Enable Field: Hysteresis Disabled */
- IOMUXC_SetPinConfig(
- IOMUXC_GPIO_SD_B1_10_FLEXSPI_A_DATA01, /* GPIO_SD_B1_10 PAD functional properties : */
- 0x10F1u); /* Slew Rate Field: Fast Slew Rate
- Drive Strength Field: R0/6
- Speed Field: max(200MHz)
- Open Drain Enable Field: Open Drain Disabled
- Pull / Keep Enable Field: Pull/Keeper Enabled
- Pull / Keep Select Field: Keeper
- Pull Up / Down Config. Field: 100K Ohm Pull Down
- Hyst. Enable Field: Hysteresis Disabled */
- IOMUXC_SetPinConfig(
- IOMUXC_GPIO_SD_B1_11_FLEXSPI_A_SS0_B, /* GPIO_SD_B1_11 PAD functional properties : */
- 0x10F1u); /* Slew Rate Field: Fast Slew Rate
- Drive Strength Field: R0/6
- Speed Field: max(200MHz)
- Open Drain Enable Field: Open Drain Disabled
- Pull / Keep Enable Field: Pull/Keeper Enabled
- Pull / Keep Select Field: Keeper
- Pull Up / Down Config. Field: 100K Ohm Pull Down
- Hyst. Enable Field: Hysteresis Disabled */
- }
复制代码- 完成上述修改后,重新编译iMXRT1020_QSPI工程就可以生成适合RT1024的flash driver文件(cfx文件)
在附件中,测试工程(hello_world工程),还有修改完成了的debug脚本文件与新生成的Flash driver文件,有兴趣的小伙伴不妨一试。 |