Is there code for a high speed SPI Slave?
blittled
Posts: 681
I'm working on a project that needs a SPI slave that works at approx. 1MHz. I have the Chameleon PIC and that SPI Slave driver runs at 100KHz. Is there one I missed in the OBEX or has someone worked on one? Thanks!
Comments
It's a pity the Prop lacks a WAIT_Pedge opcode, (to allow avoid of WAITPEQ WAITPNE pairs) for the lowest overhead sync-to-edge.
The classic pseudo minimal code for Serial RX, is
I think there is a way to synth a WaitEdge, if you do not mind using some resource :
Config a COG counter in feedback mode, and now we have two pins to mask.
PinA= SPI CLK, and PinB = !PinA
This true edge approach could also be used for i2c, and might allow a prop to hit the 3.4MHz i2c speed bin ?
I can find this, re Ardunio SPI speeds : ["It's possible to set the SPI clock to 8, 4, 2, 1MHz, 500, 250, 125kHz (Assuming a 16MHz system clock). "]
In Pseudo code, Duplex is along the lines of
Which should be good for ~ 2.75MHz, so should cover the 2MHz speed choice above.
As always, start with the lowest speed for testing, and then increase.
Thanks,
David
Edit: I guess this is a dumb question. I realized after posting it that you can surely use MPLAB X on the Mac to develop code for this board and also their own modification of the Arduino IDE.