cancel
Showing results for 
Search instead for 
Did you mean: 

Logging data to USB

andrea6388
Associate II
Posted on September 16, 2016 at 16:54

Hello to everyone,

I am developing an application that reads data from sensors mounted on a STM32L4 discovery board, but since I need to log for hours I need to save data on a big storage support, such as an USB.

Is it possible to do so using the microUSB link on the board?

I read some posts here suggesting to use the DFU usb profile, but I don't think this is the right case...

Has someone some sample code or at least any useful suggestion on how to implement the function I described?

Thank you

#power #stm32l4 #usb #stm32cube
5 REPLIES 5
Posted on September 16, 2016 at 19:18

You'd probably want an MSC OTG w/FATFS, the F4 DISCO had a firmware upgrader example that demonstrated the use of USB Sticks to update the board, but could just as easily write files, etc.

Not using the L4 or HAL/CUBE, but I'd presume a similar set of functionality would be workable.

Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..
andrea6388
Associate II
Posted on September 20, 2016 at 11:48

Thank you clivel,

in fact I've based my program on the stm32f4 FATFS example. The problem that I have is that seems that Vdd pin is not managed, so the usb is not powered (I measured it with a tester and I can see it since USB LED is turned off).

If I force that pin to high as a generic IO pin I get only 3V out, which are not sufficient to power on the device.

Has someone some suggestions about it?

andrea6388
Associate II
Posted on September 20, 2016 at 12:42

An update:

I managed to correctly handle the Vdd line by acting on PowerSwitchOn pin; now I have almost 5V (really 4.7, there are some losses around...).

But since the voltage is sent to USB, a continuous series of interrupts is issued and the program flow is stopped. 

Any clue?

andrea6388
Associate II
Posted on September 20, 2016 at 13:15

I also attach a screenshot where I show the interrupt register: it seems it's the HPRTINT interrupt that is occurring but no library function manages it.

0690X00000604vKQAQ.png

andrea6388
Associate II
Posted on September 20, 2016 at 13:32

It seems I got it... 

the function that chooses between interrupts seems to do not correctly interprete the connection interrup HPRTINT...

More correctly the values that I see from Registers tab in IAR debugger do not agree with value assigned by the function USB_ReadInterrupts:

0690X00000604vPQAQ.png