0
\$\begingroup\$

I am looking at the STM32 F4 series Discovery board. I have the eval board on my desk currently. I want to use this system to send data from USB to a 3 byte parallel data bus using an external clock source. I am using the STM32407 chip. I need to input data from a PC through the USB bus. My wish list is for the chip to handle a 2 MHz external clock rate and load the 3-byte GPIOs every clock cycle. That would be 2MHz x 24bits = 48 Mbits/s or 6 MBytes/s if my math is correct. The output from the STM32 GPIO would need to be smooth as the USB would be in packets. Is the 2 MHz possible? Can I go faster? Thank you very much.

\$\endgroup\$
  • \$\begingroup\$ What speed does the USB on the SoC support? Assuming you need to buffer the data, is there enough RAM, and a DMA facility to keep the USB fed? \$\endgroup\$ – Sean Houlihane May 24 '16 at 22:11
  • \$\begingroup\$ It has the on-the-go OTG-USB slave/master port. It says USB full speed. The STM32F407 chip has 192 KBytes of ram. I know very little about the direct memory access of this chip. I bought the eval kit to learn about this chip and it looks promising and fun. I am a complete novice about this chip. I would expect one would set the ram buffer size of the USB system and it would flag the PC when data is needed. All this to be done in the background. Code should then increment a position counter and move the next three bytes to the GPIO ports on a pin change. \$\endgroup\$ – Doug May 24 '16 at 23:54
1
\$\begingroup\$

6 MBytes/s through USB full-speed 12Mbit USB is impossible. So no 2MHz outside clock is not possible through that interface.

A more feasible target through that interface might be about 0.5MB/s over USB. Loading a 3-byte GPIO, would be about 0.5/3, or 167kHz.

The STM32F4 Discovery board (part number STM32F4DISCOVERY) does not have the USB high-speed, 480Mbit, interface implemented, so you'll need to build that (I vaguely remember something about a daughterboard with some more peripheral interfaces, might I might be wrong).

You'll need to check out the library code to drive that peripheral. It runs at 168MHz, which is 28 cycles/byte. ARM load and store instructions are 2 cycles, so 28 cycles isn't many instructions. Worse, GPIO ports are only 16 bits wide, so it's going to be a couple of writes to set up the 24 bits. Depending on the 24-bit bus, it might need a handshake too. Each of those writes is 2 cycles. IIRC DMA runs at about 1/4 CPU frequency (I'd need to dig hard to find that).

It only has 192kB of RAM, so say 180kB for buffers. That is only 3% of your data rate, i.e. 33milliseconds, which isn't very 'luxurious'.

So I guess it might be feasible, but it is likely to be a hard piece of code to write and polish.

I'd have to do some tests to get a better sense for what is reasonable.

I might try something like a BeagleBone Black, i.e. about 4-5x more CPU. It has two RISC CPU's on SoC too, which could offload the low-level I/O, and lots of I/O pins. It might even have 32bit wide ports (maybe someone else can comment).

PS:
I wrote and polished code to toggle one pin on STM32F103, which ran at a CPU clock of 72MHz. IIRC it got 12MHz doing no processing at all. So 2MHz, with two I/O port writes, with USB processing, but just over 2x faster clock (which will suffer program memory wait states), seems impossible.

\$\endgroup\$
  • \$\begingroup\$ I like the BeagleBone Black. It is a lot faster. However, it does a lot. It is like my back hoe. It does a lot of things but does not do one thing very well at least when I am using it. \$\endgroup\$ – Doug May 25 '16 at 0:03
  • \$\begingroup\$ @Doug - I think the BeagleBone gives you a few things, but mainly the two 200MHz RISC cores, lots of RAM, and High-speed USB. \$\endgroup\$ – gbulmer May 26 '16 at 3:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.