cancel
Showing results for 
Search instead for 
Did you mean: 

USB Voice Demo and FreeUserBuffer()

brunoalltest
Associate II
Posted on February 17, 2009 at 22:49

USB Voice Demo and FreeUserBuffer()

3 REPLIES 3
brunoalltest
Associate II
Posted on May 17, 2011 at 13:03

Hi,

I´m developing an kind of microphone audio device and I´m using the ''USB Voice Demo'' of ''STM32 USB firmware library'' as start.

Today I was reading the USB part of the ''RM008 - STM32Fxxxx Reference Manual'' on page 475 I´ve found the following statement about isochronous transfers.

Quote:

At the end of each transaction, the CTR_RX or CTR_TX bit of the addressed

endpoint USB_EPnR register is set, depending on the enabled direction. At the same time, the affected DTOG bit in the USB_EPnR register is hardware toggled making buffer swapping completely software independent

However, on the ''Endpoint 1 callback routine'' of ''USB Voice Demo'' there is call to the FreeUserBuffer() function, who only action is to toggle the DTOG bit. Could anyone explain me what is the purpose of this call?

Thanks,

Bruno

brunoalltest
Associate II
Posted on May 17, 2011 at 13:03

No replies but after a few tests I´ve come to a conclusion.

The USB hardware toggle them automatticaly and can access both buffers without the user calling FreeUserBuffer().

But the user(firmware functions) can only access both buffers if he calls FreeUserBuffer(). If he don´t call, he will be able to copy data from/to only one of the PMA buffers.

Now that I know that, the name of the function seems pretty obvious to me.

brunoalltest
Associate II
Posted on May 17, 2011 at 13:03

If anyone is interested in my testing code (and working USB microphone) I´m attaching it here.

It generates periodic 100 Hz sine (80 points per cycle @ 8000 Hz and 16 bits) that that needs 10 packets of 16 bytes to be transmitted to the PC .

There are some comments for USB Mic newbies on the code. Hope it helps someone in the future.

[]´s

Bruno

[ This message was edited by: brunoalltest on 18-02-2009 03:30 ]