cancel
Showing results for 
Search instead for 
Did you mean: 

Reading uSD Card

Rick MC
Associate III
Posted on March 30, 2018 at 11:03

Hello! I'm using an STM32F769I-Discovery board. I'm trying to read/write a text file on the uSD card. Since I'm a beginner I started with the example in STM32Cube\Repository\STM32Cube_FW_F7_V1.9.0 - Copia\Projects\STM32F769I_EVAL\Applications\FatFs\FatFS_uSD. 

I simply have inserted my uSD card in the CN5 connector and run the application. Problem is the code encounters an Error Handler with the message 'An MPU or Execute Never (XN) default memory map access violation has occurred on an instruction fetch'.

I debugged the code and I saw the problem is in function HAL_I2C_Mem_Read. I can't understand why..

How can I solve the problem?

Thanks

7 REPLIES 7
Farhan Khan
Associate II
Posted on March 30, 2018 at 12:03

Go through the user manual of STM32F769I-Discovery board and confirm whether you need to make some jumper settings.

Posted on March 30, 2018 at 14:03

What toolset are you using, they build and download fine under Keil

There is an I2C attached co-processor monitoring some external pins, here the MicroSD's 'Card Detect' pin.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Rick MC
Associate III
Posted on March 30, 2018 at 14:08

I checked the manual but I don't see any configuration to set.. I dug deeper in my problem and I found out the issue is related to I2C. 

I'm using IAR Embedded Workbench. 

There is an I2C attached co-processor monitoring some external pins, here the MicroSD's 'Card Detect' pin.

What is this for?

Rick MC
Associate III
Posted on March 30, 2018 at 14:10

I'm using a STM32F769I Discovery board while the example code is supposed to be for the corresponding evaluation board. 

Posted on March 30, 2018 at 16:42

Some of these boards are pin constrained due to SDRAM, LCD, etc and low bandwidth GPIO are moved to 'IO Expander' type device

For FatFS/SDCard prototype/templates on STM32F769I-DISCO look at

STM32Cube_FW_F7_V1.11.0\Projects\STM32F769I-Discovery\Applications\Display\LCD_PicturesFromSDCard

STM32Cube_FW_F7_V1.11.0\Projects\STM32F769I-Discovery\Examples\JPEG\JPEG_DecodingUsingFs_DMA

Which use the proper BSP source

STM32Cube_FW_F7_V1.11.0\Drivers\BSP\STM32F769I-Discovery\stm32f769i_discovery.c

STM32Cube_FW_F7_V1.11.0\Drivers\BSP\STM32F769I-Discovery\stm32f769i_discovery.h

STM32Cube_FW_F7_V1.11.0\Drivers\BSP\STM32F769I-Discovery\stm32f769i_discovery_sd.c

STM32Cube_FW_F7_V1.11.0\Drivers\BSP\STM32F769I-Discovery\stm32f769i_discovery_sd.h

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Posted on March 30, 2018 at 16:47

Ok, so DISCO uses PI15

STM32Cube_FW_F7_V1.11.0\Drivers\BSP\STM32F769I-Discovery\stm32f769i_discovery.h

/**

  * @brief SD-detect signal

  */

♯ define SD_DETECT_PIN                        ((uint32_t)GPIO_PIN_15)

♯ define SD_DETECT_GPIO_PORT                  ((GPIO_TypeDef*)GPIOI)

♯ define SD_DETECT_GPIO_CLK_ENABLE()          __HAL_RCC_GPIOI_CLK_ENABLE()

♯ define SD_DETECT_GPIO_CLK_DISABLE()         __HAL_RCC_GPIOI_CLK_DISABLE()

♯ define SD_DETECT_EXTI_IRQn                  EXTI15_10_IRQn

EVAL uses IO_PIN_15

STM32Cube_FW_F7_V1.11.0\Drivers\BSP\STM32F769I_EVAL\stm32f769i_eval.h

♯ if defined(USE_IOEXPANDER)

♯ define XSDN_PIN                       IO_PIN_16

♯ define MII_INT_PIN                    IO_PIN_13

♯ define RSTI_PIN                       IO_PIN_11

♯ define CAM_PLUG_PIN                   IO_PIN_12

♯ define TS_INT_PIN                     IO_PIN_14

♯ define AUDIO_INT_PIN                  IO_PIN_5

♯ define OTG_FS1_OVER_CURRENT_PIN       IO_PIN_6

♯ define OTG_FS1_POWER_SWITCH_PIN       IO_PIN_7

♯ define OTG_FS2_OVER_CURRENT_PIN       IO_PIN_8

♯ define OTG_FS2_POWER_SWITCH_PIN       IO_PIN_9

♯ define SD1_DETECT_PIN                 IO_PIN_15

♯ define SD2_DETECT_PIN                 IO_PIN_10

♯ define SD_DETECT_PIN                  SD1_DETECT_PIN

♯ endif /* USE_IOEXPANDER */
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Farhan Khan
Associate II
Posted on March 31, 2018 at 07:13

It's not that difficult to generate code for uSD card using STM32CubeMX. I will suggest you do that for the board you have.