cancel
Showing results for 
Search instead for 
Did you mean: 

stm32F4 BACKUP SRAM and USB HID conflict

jakub
Associate
Posted on November 25, 2014 at 15:37

Hi, usb hid works form me great on discovery f4 but I have a problem with saving to backup sram and backup rtc after USB initialization. I would like to create a program, which is waiting for character from the USB then enters information into backup sram or

backup 

rtc. Put data into backup memory works without USB initialization. But when I want to write something to it after the USB initialization compiler does not detect an error in the program but the memory content does not change, no entry into the memory. Initialization looks like this:

   USBD_Init (& USB_OTG_dev,

   USB_OTG_FS_CORE_ID,

   & USR_desc,

   & USBD_HID_cb,

   & USR_cb);

Any ideas? I have tried many of variance startup but nothing is working. I did off usb global init, stop device, disconnect device... nothing seems to be working.

Every new idea will be helpful!

Regards. 

Amidns

#backup #usb-sram-stm32f2-backup #usb-hid #stm32f4
13 REPLIES 13

To the original problem, that initalizing USB prevents writing to backup SRAM.

Which STM32, what code, which USB, in which mode, in which moment of USB initialization does the backup ram cease to be writable, how exactly does the problem demonstrate itself, what did you do to verify that backup sram can't be written, how is VBAT connected, did you verify that backup domain access is still enabled...?

JW

BillThePlatypus
Associate II

OK, I figured it out. For some reason, the standard libraries sets the reset flag for the PWR register, but does not clear the flag afterwards. To solve this, after initializing the USB connection, call:

RCC_APB1PeriphResetCmd(RCC_APB1Periph_PWR, DISABLE);

Afterwards, you may have to adjust registers in the RCC_APB1Periph_PWR register. I would recommend doing backup SRAM initialization after USB initialization.

As far as I can tell, this doesn't affect any USB functionality, but allows the backup SRAM to work.

Thanks for coming back with the answer, but...

For some reason, the standard libraries sets the reset flag for the PWR register, but does not clear the flag afterwards. T

What standard libraries? The SPL-based USB Host and Device, for 'F4? In which file, function?

Thanks,

JW