Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can I set MOSI default HIGH, and set CS low separately for ~1ms? #59

Open
BOBBEAR82 opened this issue Jul 6, 2017 · 6 comments
Open

Comments

@BOBBEAR82
Copy link

Hello,
I am doing a project using RPi to talk with Linear LTC6804 (battery monitoring chip) in SPI. I am using Python with spidev module to control SPI communication. However, it looks like the default MOSI pin signal is LOW, while the LTC6804 requests MOSI default HIGH.

See below in good communication the LTC6804 requests MOSI default HIGH. Also before sending request on MOSI, the CS needs to be set LOW for 0.3ms for waking up the chip.
spi_communication_good

See below in bad communication with LTC6804 using functions from spidev with MOSI default LOW. I cannot find how to set MOSI pin default HIGH with spidev.
spi_communication_bad

So see someone can help out:

  1. how can I set MOSI pin default HIGH when using spidev in Python? Or some other ways to achieve that?
  2. how can I set CS pin LOW for ~1ms when still using spidev in Python?
    I want to get exactly the same output from RPi as the first attached screenshot.

Thank you!

@SofiaRafael
Copy link

Hi,
Did you arrive at any conclusion about this?

Thank you very much,
Sofia

@Troyhy
Copy link

Troyhy commented Nov 25, 2019

I'm having similar issues. Any solution?

@semininja
Copy link

You may be able to get the same effect as MOSI default HIGH (also called "active low") by inverting the data you're sending (i.e. flipping each bit before transmission, e.g. converting 0b00110011 to 0b11001100). You can do this easily; if foo is a byte of data, instead of spi.xfer(foo) you'd spi.xfer(~foo).

@semininja
Copy link

As far as setting the CS pin to wake up the chip, will it work if you just send a byte (or a few bytes) of non-data (e.g. 0x00 or 0xFF etc.) first? My cursory inspection of the datasheet implies that for the LTC6804, that should work, although I haven't taken the time to fully understand the function of the device.

@Troyhy
Copy link

Troyhy commented Nov 27, 2019

I believe the OP described the situation well.
I have Arduino witch is generating same SPI command, but data line rests HIGH, but is not inverted. CS will wake the device.
Raspberry sends same command, but MOSI is resting in LOW state and cannot get chip to wake up.

Problem here is that this is not direct SPI connection, but trough LTC6820 isoSPI bus converter.
RaspBerry <-- SPI --> LTC6820 <-- isoSPI --> LTC6804
image

Next step is to add OR gate in MOSI line that another GPIO line can force MOSI up during WAKEUP sequence

@Troyhy
Copy link

Troyhy commented Nov 28, 2019

I can confirm that I got this working with help of additional IO line witch will force MOSI line rest to HIGH. Simple solution with 2 shotky diodes was enough to achieve this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants