AnsweredAssumed Answered

STM32L433 USB VCP Problem

Question asked by dal_pont.gianluca on Apr 5, 2017

Good evening everyone,

I'm trying to use the L433 USB as VCP using HAL Drivers, to receive data from PC and transmit the response to the PC.

I'm following the STM32L452RE example "Standalone CDC" from the CubeMX examples, but i'm having some troubles.

 

If I set the Rx buffer only in the Init, after the first reception the buffer where the data are stored (in the function called ReadPMA) isn't the one i've set previously.

This is the current flow of the program:

1. USB Init

2. USB Start, Set Rx Buffer and Set Tx Buffer, then i call the ReceivePacket function

3. Reception Callback (the buffer is filled with the data i'm expecting)

4.Data processing. After that i call the Tx function

5. In the Tx function i Set the Tx Buffer and then call the TransmitPacket function 

6. I call the ReceivePacket function to put the USB in reception

 

The next data i receive are not stored in the buffer i set previously, and the ReadPMA function cause an HardFault.

 

What and where could be the problem?

 

Thanks in advance and sorry for my poor english!

Outcomes