SPI Slave implemented on prop
pems
Posts: 70
Just curious if there is any prior art for implementing an SPI Slave on a prop
In my continuing efforts to come up with a framework of marrying a prop to another MCU, i've implemented a simple yet effective SPI Slave mechanism running on one cog.
The protocol is very simple:
NSS on
1st byte: command (read or wright data)
2nd byte: register address to read/write into (i have a 0xff longs of hub ram allocated as SPI accessible registers)
next bytes: data in longs (has to be a multiple of 4 bytes of course)
NSS off
Currently it only runs at laughable "under 1Mbps", but i plan to optimize the heck out of it, to make it be able to run faster
I'll share this code soon if anyone is interested to use it or help with optimizations
Cheers
In my continuing efforts to come up with a framework of marrying a prop to another MCU, i've implemented a simple yet effective SPI Slave mechanism running on one cog.
The protocol is very simple:
NSS on
1st byte: command (read or wright data)
2nd byte: register address to read/write into (i have a 0xff longs of hub ram allocated as SPI accessible registers)
next bytes: data in longs (has to be a multiple of 4 bytes of course)
NSS off
Currently it only runs at laughable "under 1Mbps", but i plan to optimize the heck out of it, to make it be able to run faster
I'll share this code soon if anyone is interested to use it or help with optimizations
Cheers
Comments
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Searider
things could be unrolled further (resulting in huge mess) but i think the bottleneck will still be the wrlong/rdlong. I thought of implementing some kind of caching, but that would complicate things.
EDIT: updated the code with jump table mechanism (for cases if more commands are needed)
Post Edited (pems) : 11/9/2008 2:35:07 AM GMT
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Searider
@ Pems : You seem to be on the right track. If it's a dedicated SPI peripheral and you want even faster throughput you could use multiple Cogs - One simply catches transitions and throws them into a ring buffer, another Cog can assemble the bytes / packets and executes them. That will get the clock rate up high.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Searider