cancel
Showing results for 
Search instead for 
Did you mean: 

USB device and eeprom writing

VCapu
Associate III

I am using a STM32F4 on a custom board that is connected to PC software through USB (configured as custom HID device). I have this problem: when the PC send data to the board, the data has to be written in the eeprom memory (one byte at each transmission), but it seems that the writing operation is too slow and the communication stop. What could be the solution? I tried to make slower request of writing from the PC software but nothing changes. Thank you

5 REPLIES 5

> What could be the solution?

Multitasking, in any of its form, starting from state-machine-based cooperative multitasking (a.k.a. polling), through interrupts-based approach, all the way to using any of the RTOSes.

JW

TDK
Guru

Do the operation within the main loop instead of the interrupt. Transfer it to a buffer and set a flag such that the main loop knows to start writing.

If you feel a post has answered your question, please click "Accept as Solution".
VCapu
Associate III

I managed in that way, with a small buffer, but the problem is that a great number of data is written each time and the quantity is not fixed, so I would prefer to write the bytes one at a time. I am trying to do that by slowing the commands of writing, but I have still some problem.

  1. Try to write to the eeprom less data, less frequently (cache data, rewrite only changed bytes). OTOH if the eeprom can write more than a byte at once (by "pages", bursts) - use that mode.
  2. Increase the bus frequency of the I2C: if it is 100 KHz, increase to 400 if the eeprom allows (it should).
  3. Detect I2C errors and implement recovery. This couples with (1), While you recover I2C, the app works with the cache and its flow is not affected.
  4. Ditch that old eeprom and use this.
VCapu
Associate III

I solved in that way at the end. Thanks