AnsweredAssumed Answered

Help with MQX SDHC support on TWRK60F120M

Question asked by Andrew Clegg on Nov 23, 2014
Latest reply on Nov 27, 2014 by soledad

Hi, I am getting really stuck with trying to use the built in SDHC slot on the TWRK60F120M. I am trying to use MQX IO drivers for direct block-level access, rather than with MFS.

 

If I try to initialize the SD card support with ProcessorExpert (either SDHC_LDD or Init_SDHC), then I can use the MQX IO driver to open the device:

MQX_FILE_PTR com_handle = fopen(BSP_SDCARD_ESDHC_CHANNEL, NULL); _io_sdcard_install("sdcard:", (void *)&_bsp_sdcard0_init, com_handle); sd_card_ptr = fopen("sdcard:", 0); uint32_t num_sectors; _io_ioctl(sd_card_ptr, IO_IOCTL_GET_NUM_SECTORS, &num_sectors); _io_write(sd_card_ptr, &current_data_block, 512);

This is minimalised code, my real version has error checking etc. I get an sd_card_ptr which is not null. The IOCTL command runs, but the num_sectors is not correct. The _io_write call fails (returns IO_ERROR_WRITE).

 

If I don't use either of the ProcessorExpert components, then the 3rd line (fopen("sdcard:", 0)) fails.

 

So my question is - am I doing anything really stupid here? Do I need the processor expert components to initialize the card, or is this just causing problems? Is it OK to read/write directly to the card without going through MFS? Is there a better way of doing this - all I really need to do is read and write 512 byte blocks to the card?

 

Many thanks

Outcomes