Jump to content

Building a compatible SPI Slave device


Recommended Posts

Hi guys,


I'm currently in the process of planning a PIC-based capacitive touch device (2D panel, 12cm x 12cm). First and foremost I want to use it via USB but eventually it could communicate via serial connection. So there is a chance it might output data for midibox projects.


Wondering what would be the best way of talking to a midibox I had a look at the serial-register-based DOUT modules (e.g. http://ucapps.de/mbhp/mbhp_doutx4_r5.pdf ).

So what we have here is an SPI-based communication and a hardware layout for a 2x5 pin header which I could easily use.


I'm just having a hard time deciding on what to do with power levels. If no USB power is provided the device could be supplied by the 5V power from the midi box (also made available through the pin header). However, since it's a 3.3V IC a power regulator will have to be used. Easy.

But I guess the SPI signal levels from the midibox master will be 5V as well, right? So do you think I'll run into some problems when my 3.3V PIC microcontroller will receive e.g. an SPI clock at 5V? I guess it will always have to send its data (MISO-path) at 3.3V, right?



What would be suitable (yet simple!) hardware workarounds to provide a bus interface that is flexible in terms of signal levels?

Link to comment
Share on other sites

I wonder how these eBay PCBs work. You basically only see what could be a bunch of transistors.



in theory getting the level down could be accomplished by using a zener diode

while amplification could be done by an appropriate MOSFET.

(assuming that my device voltage is generated from the host voltage by using a regulator IC)


if I let my device operate somewhere between 2.3V-3.3V and assume midibox (or whatever SPI master there is) runs at 3.3V-12V the situation is pretty clear:


Device inputs (SCK, LCK, ...) always require voltage reduction (zener diode) while Device outputs (ser data, ...) need amplification.



do you think this will work?

Link to comment
Share on other sites

It depends on the microcontroller which is connected to the SPI device.


Modern microcontrollers are typically supplied at 3.3V, but they have 5V tolerant inputs -> no voltage reduction required.

For level shifting (3.3V -> 5V) a 74HCT based buffer is sufficient, see also the MBHP_CORE_STM32F4 schematic (http://www.ucapps.de/mbhp/mbhp_core_stm32f4.pdf) where I'm using a 74HCT541 to shift the outputs levels of two independent SPI ports from 3.3V to 5V


I don't know any MIDIbox which requires more than 5V at the SPI port ;-)


Best Regards, Thorsten.

Link to comment
Share on other sites

I have done some further research. Most of the inputs actually are 5.5V tolerant so I'll just roll with that.


The outputs may also produce 5.0V in open-drain configuration when using an external pullup.


I'm just not sure whether this is also true for the SOUT pin of the SPI module that is routed through an remappable peripheral pin. So I decided to use a single-channel buffer IC (NC7SZ125). Guess I'll be fine with this.

FYI: I'm using a PIC24FJ128GC010



Thanks for your help, guys

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Create New...