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
Posted on November 25, 2014 at 17:51

Wouldn't the code fiddling with the RAM be more pertinent to the problem? Are the clocks to the backup/power domain enabled, and have you unlocked access to it?

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
jakub
Associate
Posted on November 26, 2014 at 08:15

My function  write_to_backup_sram:

int8_t write_to_backup_sram( uint8_t *data, uint16_t bytes, uint16_t offset )

{

 uint8_t* base_addr = (uint8_t *) BKPSRAM_BASE;

  uint16_t i;

 RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_BKPSRAM, ENABLE);

  RCC_APB1PeriphClockCmd(RCC_APB1Periph_PWR, ENABLE);  

  PWR_BackupAccessCmd(ENABLE);               

  PWR_BackupRegulatorCmd(ENABLE);   

  for( i = 0; i < bytes; i++ ) { 

    *(base_addr + offset + i) = *(data + i);  //TEST VALUES

  }

  PWR_BackupAccessCmd(DISABLE);                  

  return 0;

}

   Something is missing? But it works without USB init.

Posted on March 17, 2016 at 12:05

Did anyone ever find an answer to this? 

I have exactly the same problem with an STM32F205VE. I can read and write from the battery backed up SRAM just fine until I implement USB VCP. As soon as the USB stack is initialised, the backup SRAM seems to become read only! I can find no mention of this 'feature' in any datasheet.

The processor does not throw a fault if you try to write to to the backup SRAM, it just doesn't update the RAM. It is also no longer possible to update the backup SRAM via JTAG once the USB has been initialised. again, there is no error, it just does not change the values. I have tried every possible Google search that I can think of to find a solution to this problem and this post is the only thing I have found!

Can anyone throw any light on this problem?

Regards

Tim 

Posted on March 17, 2016 at 16:05

Did anyone ever find an answer to this?

Hard to say, there have been a number of issues with USB_Init() stomping on things, in different threads. Might want to Google a bit more generally.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
jay1991
Associate II
Posted on May 24, 2016 at 08:38

How you read this data?

Posted on May 24, 2016 at 15:11

How you read this data?

The same way you read all the other memory. You could use a pointer, a structure pointer, or via sections and linker scripts or scatter files.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
jay1991
Associate II
Posted on May 25, 2016 at 07:15

thank you clive1.

BillThePlatypus
Associate II

Has anyone found a solution to this? I am running into the same problem, and nothing I can find in the documentation indicates why.

Try to be more specific.

JW