AnsweredAssumed Answered

windows gets hanged in USB MSC (with uSD) example

Question asked by j.martin on Dec 25, 2015
Latest reply on Dec 27, 2015 by j.martin
Hello,

For USB Mass storage, I've followed [DEAD LINK /public/STe2ecommunities/mcu/Lists/cortex_mx_stm32/Flat.aspx?RootFolder=/public/STe2ecommunities/mcu/Lists/cortex_mx_stm32/USB%20CDC%20on%20STM32L%20device%20%20unable%20to%20connect%20to%20host&currentviews=5635]this post and connect PA11,12 directly D+,D- and used internal pull-up(SYSCFG_USB) for STM32L151. It works without AF function declaration. I've declared 2K stack size with 1K heap. Windows can detect "STM32 Mass Storage" as a drive, but, in the properties info tab:
"Device USB\VID_0483&PID_5720\C24C3DB3DB18 could not be migrated".

Also, when I insert a uSD card in the socket and power on system, Windows gets hanged/ can't access.

My purpose is to check primarily whether I can read/copy files from uSD card to PC. Am I missing any code segment to add? Previously, I checked my SD card with simple FATFS read/write following Clive's code.

Thank you for your kind comment.


#include "nucleo15x_sdio.h"
#include "nucleo15x_sdio_sd.h"
......................
void SD_LowLevel_Init(void)
{
........
}
void SD_LowLevel_DeInit(void)
{
........
}

void SDIO_IRQHandler(void)
{
  SD_ProcessIRQSrc();
}

void USB_Interrupts_Config_1(void)
{
  NVIC_InitTypeDef NVIC_InitStructure;
  NVIC_PriorityGroupConfig(NVIC_PriorityGroup_1);
  NVIC_InitStructure.NVIC_IRQChannel = USB_LP_IRQn;   
  NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 1;
  NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;
  NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
  NVIC_Init(&NVIC_InitStructure);
    
  NVIC_InitStructure.NVIC_IRQChannel = SDIO_IRQn;
  NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;
  NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;
  NVIC_Init(&NVIC_InitStructure);
    
//  NVIC_InitStructure.NVIC_IRQChannel = SD_SDIO_DMA_IRQn;
//  NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;
//  NVIC_Init(&NVIC_InitStructure);

//  NVIC_InitStructure.NVIC_IRQChannel = USB_FS_WKUP_IRQn;
//  NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;
//  NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
//  NVIC_Init(&NVIC_InitStructure);        
}

void USB_Set_System(void);
{
  RCC_APB2PeriphClockCmd(RCC_APB2Periph_SYSCFG, ENABLE);    
  RCC_AHBPeriphClockCmd( RCC_AHBPeriph_GPIOA,ENABLE) ;   

  EXTI_ClearITPendingBit(EXTI_Line18);
  EXTI_InitStructure1.EXTI_Line = EXTI_Line18;
  EXTI_InitStructure1.EXTI_Trigger = EXTI_Trigger_Rising;
  EXTI_InitStructure1.EXTI_LineCmd = ENABLE;
  EXTI_Init(&EXTI_InitStructure1);
}

int main(void)
{    
  USB_Set_System();

  //MAL_Config();  
  SD_Init();
 
  //Set_USBClock();
  RCC_APB1PeriphClockCmd(RCC_APB1Periph_USB, ENABLE);
 
  USB_Interrupts_Config_1();
 
  SYSCFG_USBPuCmd( ENABLE );  // Again called in USB_Cable_Config(ENABLE) of USB_Init() routine.
  delay_us(100000);  // 100ms delay

  USB_Init();
 
  //  while (bDeviceState != CONFIGURED);
 
  while (1)
        {
        }

}

Outcomes