Which communication protocol to use?

Status
Not open for further replies.

ohnoitsaninja

Well-known member
I'm playing with adding a co-processor to my teensy projects (cheapo maple mini clones) to crunch artificial neural networks. Basically the teensy will send two 16-bit ints, and expect to get back 128 16-bit ints.

I'm trying to move 128 uint16_t variables, either as a chunk or a stream, whichever is faster. I've got a UART demo working between a teensy-lc on serial1 and the maple at 380000 baud that sends one byte at a time or as a chunk. I would like to move the data faster, I2C and SPI are both faster, and SPI DMA is the smart way to go, but I've thrown many hours trying to get an I2C or SPI demo working at all or at the same speeds as my uart demo without any success. I tried some DMA but I'm way over my head. I couldn't find a good write up for SPI slave, the ones I tried to adapt from arduino failed in a way I can't figure out, I seems to be the SPI speeds not being the same, the maplemini is at 72Mhz but I thought SPISettings(250000, MSBFIRST, SPI_MODE1); would be independent of the processor speed.

I would like to be able to send the data at 1000hz, which I think is 128 variables * 2 bytes each * 1000hz = 256 kB/s, which from what I've recently learned about SPI should be easy-ish.

These work well at 380000 baud to move 64 uin16_t at a time, I suspect I can send more by editing serial1's buffer size?
http://pastebin.com/dksD42si uart tx on maple
http://pastebin.com/p18t9pgP uart rx on teensy-lc


My SPI test almost works, but the slave misses ~2/3 of the messages sent from the master. It gets better or worse based on changing the SPI speed, seemingly randomly related to raising or lowering the speed.

http://pastebin.com/dU4X8RBt SPI maple master
http://pastebin.com/b3221nQt SPI teensy-lc slave

I never got I2C to work, I think it has to do with the wire library for the maple.

I'm coming into this knowing almost nothing about communication protocol other than the basics of serial. My initial thought was to use one or two GPIO ports to send 8 or 16-bits at a time, is this a smarter way to go since I have plenty of pins? Also finding an example of the port mappings for teensy-lc is proving impossible.
 
Last edited:
I've recently been re-discovering the joys of DMA, so let me know if I can help.

Although my initial version will only send one byte per dma request. I have some bit fiddling to do as yet...
 
Hi, I just found this https://github.com/duff2013/UartEvent uart dma for Teensy 3.1, says LC not supported, curious how big of a challenge that would be to take on.

Also, how much uart could be sped up with dma in comparison to spi?

It seems very silly looking at all these unused pins while trying to cram all this data down a two wire interface, but that's what my reading seems to suggest is the best option?
 
Last edited:
Status
Not open for further replies.
Back
Top