cancel
Showing results for 
Search instead for 
Did you mean: 

de-initialize USB completely

michelemancini2
Associate III
Posted on June 16, 2014 at 10:01

Hi, I work with STM32L1 and use the USB in VCP.

The firmware work

perfectly

.

I use the library ''STM32_USB-FS-Device_Lib_V4.0.0''

and I use the example firmware ''VirtualComport_Loopback''

The usb work!. but I need

completely disable

the USB

and go to

''STOP mode''.

The problem is that

once activated

USB

, I can not

turn it off

completely

and when go in ''STOP mode'' the STM32

consumes power

(~600uA) but if not inizialize USB the STM32

consumes power

(~3uA)!

I inizialize USB:

    Set_System();

    Set_USBClock();

    USB_Interrupts_Config();

    USB_Init();

and when de-inizialize USB :

  EXTI_ClearITPendingBit(EXTI_Line18);

  EXTI_InitStructure.EXTI_Line = EXTI_Line18;

  EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Rising;

  EXTI_InitStructure.EXTI_LineCmd = DISABLE;

  EXTI_Init(&EXTI_InitStructure);

 

   RCC_APB2PeriphClockCmd(RCC_APB2Periph_SYSCFG, DISABLE);

  RCC_APB1PeriphClockCmd(RCC_APB1Periph_USB, DISABLE);

NVIC_InitTypeDef NVIC_InitStructure;

  /* 2 bit for pre-emption priority, 2 bits for subpriority */

  NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2);

  /* Enable the USB interrupt */

  NVIC_InitStructure.NVIC_IRQChannel = USB_LP_IRQn;

  NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 2;

  NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;

  NVIC_InitStructure.NVIC_IRQChannelCmd = DISABLE;

  NVIC_Init(&NVIC_InitStructure);

  /* Enable the USB Wake-up interrupt */

  NVIC_InitStructure.NVIC_IRQChannel = USB_FS_WKUP_IRQn;

  NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 1;

  NVIC_InitStructure.NVIC_IRQChannelCmd = DISABLE;

  NVIC_Init(&NVIC_InitStructure);

PowerOff();

But the USB is NOT deinizialize completely!, How I do deinizialize?

2 REPLIES 2
zzdz2
Associate II
Posted on June 16, 2014 at 10:59

Before stopping the USB clock you need to power down the peripheral.

E.g. like this:

_SetCNTR(CNTR_PDWN | CNTR_FRES);

michelemancini2
Associate III
Posted on June 16, 2014 at 16:28

thank you very much

, go in stop mode perfect!