Problem with level shifting  - Page 1
Forum section: electronics / general

author: and101
author_rank: Contributor
timestamp: July 16, 2013, 12:53:18 pm
content: I am trying to communicate between a Rasberry Pi and PIC microcontroller over an SPI interface but I have run into a problem and hopefully someone can help. The Raspberry Pi bus runs at 3.3V and the PIC is running at 5V so I am using a TXS0108E to level shift the data lines. I have used these chips before for i2c development and according to the datasheet they should work for SPI as well. The PIC is connected to a Mikroe EasyPic 7 development board and when I connect the 5V side of the TXS0108E to the pins on the dev board the data is becoming corrupted.I used a logic analyser to check the data lines when sending packets from the Raspberry Pi and it shows the data correctly on the 5v side of the level shifter when it is not connected to the PIC dev board and still works when I connect the clock line but as soon as I connect the SDI or SDO pins the data becomes corrupted. It does this even when a PIC isn't plugged into the dev board. I checked the resistance on the dev board between the two data pins and vcc and ground and it appears to be an open circuit so I don't think the lines are being pulled high or low.Does anyone have any experience with these level shifter ICs or any ideas on what might be going wrong? Any help would be greatly appreciated.

author: free_electron
author_rank: Super Contributor
timestamp: July 16, 2013, 01:29:40 pm
content: Do you have a good connection of PI ground to the other board ground ?Don't connect any other signal but ground between the boards and see what happens.. There may be a difference between those two grounds...

author: Mr Smiley
author_rank: Frequent Contributor
timestamp: July 16, 2013, 04:02:31 pm
content: Would it not be possible and easier to just drop the pic down to 3.3v

author: and101
author_rank: Contributor
timestamp: July 16, 2013, 04:44:37 pm
content: It doesn't appear to be a grounding issue, I tried tying all of the raspberry pi gpio grounds to the dev board ground and it still has the same issue.This is the buffer circuit that I am using.I have used the buffer with i2c and UART and it works fine but this is the first time I have tried doing SPI communication so I am not sure if it is the buffer circuit or the PIC dev board that is causing the problems.The circuit I am building needs to connect the PIC to an ADC and other devices running at 5V so ideally the PIC also needs to run at 5V otherwise I will need level shifters on the ADC and other chips. I am designing a solar data logging system and the idea was to use a PIC to sample a 16 bit ADC on 12 multiplexed channels several times a second and then once a minute the Raspberry Pi will request an average and max values from the PIC for each channel. By delegating the sampling to a separate microcontroller it will leave the Raspberry Pi free to do other less time critical things.

author: Mr Smiley
author_rank: Frequent Contributor
timestamp: July 16, 2013, 04:56:31 pm
content: opto'sdifferential line drivers

author: and101
author_rank: Contributor
timestamp: July 16, 2013, 07:49:30 pm
content: It looks like I might be able to get away with making the whole circuit 3.3V after all. I have found a 3.3v version of the current sensor I was going to use so hopefully everything else on the circuit will also run at 3V which will solve the level shifting problem.It is a bit of a pain that these chips didn't work for translating SPI as I was planning on building a buffer board for the Raspberry Pi to sell.

author: hw-eng
author_rank: Newbie
timestamp: July 20, 2013, 03:48:19 pm
content: Another solution:1- 4050 HEX BUFFER/CONVERTER (NON INVERTING).2- The input high level signal (VIH) can exceed the VDD supply voltage.(VDD= 3 to 20, VI =-0.5 to 15V)3- PROPAGATION DELAY TIME= 40ns (TYP.) at VDD = 10V CL = 50pF.==> PIC(VCC= +5V) --> 4050(VCC= +3V3) --> Rasberry Pi(VCC= +3V3)

author: and101
author_rank: Contributor
timestamp: July 20, 2013, 04:08:34 pm
content: After reading around the net about the TXS0108E it seems that they have a low capacitance tolerance at high data rates so it might be an issue of too much capacitance on the signal lines on the dev board. I tried connecting an SPI SRAM chip on very short leads to the Raspberry Pi using a TXS0108E level converter and it worked fine so as long as I keep the traces short on the final PCB design hopefully everything should work ok.Thanks for all of the help, now I just need to figure out all of the sampling code on the microcontroller and make it act as an SPI slave device.

author: FrankBuss
author_rank: Unknown
timestamp: July 20, 2013, 04:17:52 pm
content: These auto-direction level level shifters can have problems with high frequencies. For SPI you know the direction of all pins, better use 4 x SN74LVC1T45, if you still need 5V.