Author Topic: Problem with level shifting  (Read 7696 times)

0 Members and 1 Guest are viewing this topic.

Offline and101Topic starter

  • Contributor
  • Posts: 45
  • Country: gb
    • AB Electronics UK
Problem with level shifting
« on: July 16, 2013, 12:53:18 pm »
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.
 

Offline free_electron

  • Super Contributor
  • ***
  • Posts: 9056
  • Country: us
    • SiliconValleyGarage
Re: Problem with level shifting
« Reply #1 on: July 16, 2013, 01:29:40 pm »
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...
Professional Electron Wrangler.
Any comments, or points of view expressed, are my own and not endorsed , induced or compensated by my employer(s).
 

Offline Mr Smiley

  • Frequent Contributor
  • **
  • Posts: 324
  • Country: gb
Re: Problem with level shifting
« Reply #2 on: July 16, 2013, 04:02:31 pm »
Would it not be possible and easier to just drop the pic down to 3.3v  :-+

 :)
There is enough on this planet to sustain mans needs. There will never be enough on this planet to sustain mans greed.
 

Offline and101Topic starter

  • Contributor
  • Posts: 45
  • Country: gb
    • AB Electronics UK
Re: Problem with level shifting
« Reply #3 on: July 16, 2013, 04:44:37 pm »
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.
 

Offline Mr Smiley

  • Frequent Contributor
  • **
  • Posts: 324
  • Country: gb
Re: Problem with level shifting
« Reply #4 on: July 16, 2013, 04:56:31 pm »
opto's  :-//

differential line drivers  :-//

 :)
There is enough on this planet to sustain mans needs. There will never be enough on this planet to sustain mans greed.
 

Offline and101Topic starter

  • Contributor
  • Posts: 45
  • Country: gb
    • AB Electronics UK
Re: Problem with level shifting
« Reply #5 on: July 16, 2013, 07:49:30 pm »
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. 
 

Offline hw-eng

  • Newbie
  • Posts: 1
Re: Problem with level shifting
« Reply #6 on: July 20, 2013, 03:48:19 pm »
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)
 

Offline and101Topic starter

  • Contributor
  • Posts: 45
  • Country: gb
    • AB Electronics UK
Re: Problem with level shifting
« Reply #7 on: July 20, 2013, 04:08:34 pm »
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.
 

Offline FrankBuss

  • Supporter
  • ****
  • Posts: 2425
  • Country: de
    • Frank Buss
Re: Problem with level shifting
« Reply #8 on: July 20, 2013, 04:17:52 pm »
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.
So Long, and Thanks for All the Fish
Electronics, hiking, retro-computing, electronic music etc.: https://www.youtube.com/c/FrankBussProgrammer
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf

 

- - -
-->