Hello,
Are you testing on Full Speed mode? I was able to create a basic example for TWR-K65F180M and dev_msd_disk_bm_twrk65f180m example (KSDK 1.3) and it worked well, this is what I did:
In disk.h, I modify TOTAL_LOGICAL_ADDRESS_BLOCKS_NORMAL to 1024 in order to use a 512kB disk size, also, storage_disk pointer was modified as you did:
#if RAM_DISK_USES_SDRAM
#define TOTAL_LOGICAL_ADDRESS_BLOCKS_NORMAL (1024)
#else
#define TOTAL_LOGICAL_ADDRESS_BLOCKS_NORMAL (48)
#endif
#if RAM_DISK_USES_SDRAM
uint8_t *storage_disk;
#else
uint8_t storage_disk[DISK_SIZE_NORMAL];
#endif
In hardware_init.c file, I added SDRAM initialization (taken from SDRAM example at <KSDK_1_3_PATH>\examples\twrk65f180m\driver_examples\sdramc):
#if RAM_DISK_USES_SDRAM
FB_Type* fbbase = g_fbBase[0];
#endif
#if RAM_DISK_USES_SDRAM
/* Change the clock DIV3*/
CLOCK_SYS_SetOutDiv3(2);
CLOCK_HAL_SetClkOutSel(SIM, kClockClkoutSelFlexbusClk);
/* Sets the Flexbus security level*/
SIM_HAL_SetFlexbusSecurityLevelMode(SIM,kSimFbslLevel3);
/* Enable the FB_BE_xx_yy signal in Flexbus */
CLOCK_SYS_EnableFlexbusClock(0);
FLEXBUS_HAL_SetMultiplexControlGroup2(fbbase,kFlexbusMultiplexGroup2_FB_BE_31_24);
FLEXBUS_HAL_SetMultiplexControlGroup3(fbbase,kFlexbusMultiplexGroup3_FB_BE_23_16);
FLEXBUS_HAL_SetMultiplexControlGroup4(fbbase,kFlexbusMultiplexGroup4_FB_BE_15_8);
FLEXBUS_HAL_SetMultiplexControlGroup5(fbbase,kFlexbusMultiplexGroup5_FB_BE_7_0);
/* Init sdram pins*/
configure_sdram_pins(0);
/* Init Sdram Clock*/
CLOCK_SYS_EnableSdramcClock(0);
#endif
(Be sure to include proper header: #include "fsl_flexbus_driver.h" and #include "fsl_flexbus_hal.h") And finally, SDRAM_Init is called (also, be sure to add fsl_sdram_Driver.c and fsl_sdram_driver.h from SDRAM example) in APP_Init function:
void APP_init(void)
{
#if RAM_DISK_USES_SDRAM
SDRAM_Init();
#endif
USB_PRINTF("Enter Testapp_init\n");
And storage disk is pointing to SDRAM start address:
#if RAM_DISK_USES_SDRAM
g_disk.storage_disk = (uint8_t *)SDRAM_START_ADDRESS;
#endif
USB_Class_MSC_Init(CONTROLLER_ID, &g_msd_config, &g_disk.app_handle);
After applying these changes, I was able to use SDRAM memory for my storage disk successfully.
Are you able to test this basic example?
Regards,
Isaac