2016-01-28 12:53 AM
Hi all,
I am trying to interface with JR28F064M29EW NOR flash () using the STM32F407 MCU. However, I couldn't read the correct device ID from the NOR IC. So I want to ask whether there is anything wrong with my initialization code?Here is the initialization code: GPIO_InitTypeDef GPIO_Init_Structure; /* Enable FSMC clock */ __HAL_RCC_FSMC_CLK_ENABLE(); __HAL_RCC_FSMC_FORCE_RESET(); __HAL_RCC_FSMC_RELEASE_RESET(); /* Enable GPIOs clock */ __HAL_RCC_GPIOD_CLK_ENABLE(); __HAL_RCC_GPIOE_CLK_ENABLE(); __HAL_RCC_GPIOF_CLK_ENABLE(); __HAL_RCC_GPIOG_CLK_ENABLE(); /* Common GPIO configuration */ GPIO_Init_Structure.Mode = GPIO_MODE_AF_PP; GPIO_Init_Structure.Pull = GPIO_PULLUP; GPIO_Init_Structure.Alternate = GPIO_AF12_FSMC; GPIO_Init_Structure.Speed = GPIO_SPEED_HIGH; /* GPIOD configuration */ GPIO_Init_Structure.Pin = GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_4 | GPIO_PIN_5 | GPIO_PIN_6 | GPIO_PIN_7 | GPIO_PIN_8 | GPIO_PIN_9 | GPIO_PIN_10 | GPIO_PIN_11 | GPIO_PIN_12 | GPIO_PIN_13 | GPIO_PIN_14 | GPIO_PIN_15; HAL_GPIO_Init(GPIOD, &GPIO_Init_Structure); /* GPIOE configuration */ GPIO_Init_Structure.Pin = GPIO_PIN_3 | GPIO_PIN_4 | GPIO_PIN_5 | GPIO_PIN_7 | GPIO_PIN_8 | GPIO_PIN_9 | GPIO_PIN_10 | GPIO_PIN_11 | GPIO_PIN_12 | GPIO_PIN_13 | GPIO_PIN_14 | GPIO_PIN_15; HAL_GPIO_Init(GPIOE, &GPIO_Init_Structure); /* GPIOF configuration */ GPIO_Init_Structure.Pin = GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_2 | GPIO_PIN_3 | GPIO_PIN_4 | GPIO_PIN_5 | GPIO_PIN_12 | GPIO_PIN_13 | GPIO_PIN_14 | GPIO_PIN_15; HAL_GPIO_Init(GPIOF, &GPIO_Init_Structure); /* GPIOG configuration */ GPIO_Init_Structure.Pin = GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_2 | GPIO_PIN_3 | GPIO_PIN_4 | GPIO_PIN_5 | GPIO_PIN_9 | GPIO_PIN_10 | GPIO_PIN_12; HAL_GPIO_Init(GPIOG, &GPIO_Init_Structure); hNor.Instance = FSMC_NORSRAM_DEVICE; hNor.Extended = FSMC_NORSRAM_EXTENDED_DEVICE; /* NOR device configuration */ NOR_Timing.AddressSetupTime = 6; NOR_Timing.AddressHoldTime = 2; NOR_Timing.DataSetupTime = 8; NOR_Timing.BusTurnAroundDuration = 0; NOR_Timing.CLKDivision = 2; NOR_Timing.DataLatency = 2; NOR_Timing.AccessMode = FSMC_ACCESS_MODE_B; hNor.Init.NSBank = FSMC_NORSRAM_BANK3; hNor.Init.DataAddressMux = FSMC_DATA_ADDRESS_MUX_DISABLE; hNor.Init.MemoryType = FSMC_MEMORY_TYPE_NOR; hNor.Init.MemoryDataWidth = FSMC_NORSRAM_MEM_BUS_WIDTH_16; hNor.Init.BurstAccessMode = FSMC_BURST_ACCESS_MODE_DISABLE; hNor.Init.WaitSignalPolarity = FSMC_WAIT_SIGNAL_POLARITY_LOW; hNor.Init.WrapMode = FSMC_WRAP_MODE_DISABLE; hNor.Init.WaitSignalActive = FSMC_WAIT_TIMING_BEFORE_WS; hNor.Init.WriteOperation = FSMC_WRITE_OPERATION_ENABLE; hNor.Init.WaitSignal = FSMC_WAIT_SIGNAL_DISABLE; hNor.Init.ExtendedMode = FSMC_EXTENDED_MODE_DISABLE; hNor.Init.AsynchronousWait = FSMC_ASYNCHRONOUS_WAIT_DISABLE; hNor.Init.WriteBurst = FSMC_WRITE_BURST_DISABLE; /* Initialize the NOR controller */ if(HAL_NOR_Init(&hNor, &NOR_Timing, &NOR_Timing) != HAL_OK) { /* Initialization Error */ Error_Handler(); } #nor #fsmc #stm32f4072016-01-28 01:46 AM
Is it only the ID you can't read correctly, or also the content of memory?
Post the content of relevant GPIO and FSMC registers after the initialization. JW2016-01-28 05:31 AM
Here are the content of the registers
GPIOD_MODER 0x40020C00 AAAAAA0AGPIOD_OTYPER 0x40020C04 00000000GPIOD_OSPEEDR 0x40020C08 FFFFFF0FGPIOD_PUPDR 0x40020C0C 55555505GPIOD_IDR 0x40020C10 0000C7FFGPIOD_ODR 0x40020C14 00000000GPIOD_BSRR 0x40020C18 00000000GPIOD_LCKR 0x40020C1C 00000000GPIOD_AFRL 0x40020C20 CCCC00CCGPIOD_AFRH 0x40020C24 CCCCCCCCGPIOE_MODER 0x40021000 AAAA8A90GPIOE_OTYPER 0x40021004 00000000GPIOE_OSPEEDR 0x40021008 FFFFCFE0GPIOE_PUPDR 0x4002100C 55554550GPIOE_IDR 0x40021010 0000FFC0GPIOE_ODR 0x40021014 00000000GPIOE_BSRR 0x40021018 00000000GPIOE_LCKR 0x4002101C 00000000GPIOE_AFRL 0x40021020 C0CCC000GPIOE_AFRH 0x40021024 CCCCCCCCGPIOF_MODER 0x40021400 AA000AAAGPIOF_OTYPER 0x40021404 00000000GPIOF_OSPEEDR 0x40021408 FF000FFFGPIOF_PUPDR 0x4002140C 55000555GPIOF_IDR 0x40021410 00000FC0GPIOF_ODR 0x40021414 00000000GPIOF_BSRR 0x40021418 00000000GPIOF_LCKR 0x4002141C 00000000GPIOF_AFRL 0x40021420 00CCCCCCGPIOF_AFRH 0x40021424 CCCC0000GPIOG_MODER 0x40021800 02280AAAGPIOG_OTYPER 0x40021804 00000000GPIOG_OSPEEDR 0x40021808 033C0FFFGPIOG_PUPDR 0x4002180C 01140555GPIOG_IDR 0x40021810 000017C0GPIOG_ODR 0x40021814 00000000GPIOG_BSRR 0x40021818 00000000GPIOG_LCKR 0x4002181C 00000000GPIOG_AFRL 0x40021820 00CCCCCCGPIOG_AFRH 0x40021824 000C0CC0FSMC_BCR1 0xA0000000 00000000FSMC_BTR1 0xA0000004 00000000FSMC_BCR2 0xA0000008 00000000FSMC_BTR2 0xA000000C 00000000FSMC_BCR3 0xA0000010 000010D9FSMC_BTR3 0xA0000014 10100826FSMC_BCR4 0xA0000018 000030D2FSMC_BTR4 0xA000001C 0FFFFFFFFSMC_BWTR1 0xA0000104 0FFFFFFFFSMC_BWTR2 0xA000010C 0FFFFFFFFSMC_BWTR3 0xA0000114 0FFFFFFFFSMC_BWTR4 0xA000011C 0FFFFFFFThe content can't be read either.2016-01-28 08:43 AM
Looks reasonable. However, it's strange that for chipselects 1 and 2 there are 0s in the registers instead of their reset values; it's also strange that you initialize all 4 chipselects.
How exactly is your memory connected? And how exactly do you access it? JW2016-01-29 04:20 PM
Hi waclawek.jan,
Thanks for the help. I finally managed to resolve the problem. It turned out to be some issue with the NOR IC. Replacing the NOR IC and it works.