1

0

I'm trying to communicate with ADC via SPI using "pigpio" library. Basically I'm trying to read an ADC channel data over there i have to send 0x0800 but spi_xfer is not take more than 256 bytes any other way to deal with this or any pther instruction which help to read data from SPI device with 16 clocks and more than 256 bytes to transfer

import pigpio
import time
pi = pigpio.pi()


pi.set_mode(8, pigpio.OUTPUT)

#pi.set_mode(27, pigpio.INPUT)

# reset the board
pi.write(8, 1)
time.sleep(.1)
pi.write(8, 0)


fd = pi.spi_open(0,1000000)

while True:
    
   
    a=pi.spi_xfer(fd,[0x0800,0x0000])
    
    
    print("a is",a[1])

1 Answer 1

0

Regardless of the word size pigpio always transfers in units of a byte.

That means any value in the data parameter of spi_xfer must be in the range 0-255 (0x0-0xff).

The default word size is 8-bit bytes. You can change the word size for the Auxiliary SPI device to 1-32 bits when you open the device with spi_open.

If you do set a non-standard word size of say 16 bits you will need to send two bytes for each 16 bit word.

I suggest you experiment by trying different configuration settings until you understand what is happening.

7
  • but in pigpio clock is not same at all......clock is not constant Jul 31, 2021 at 6:43
  • What clock? There is no mention of clock anywhere in your question. You need to find someone at your workplace who is familiar with software.
    – joan
    Jul 31, 2021 at 7:43
  • which instruction use for set clock in pigpio library Aug 1, 2021 at 8:09
  • fd=pi.spi_open(0,50000) (a,b)=pi.spi_xfer(fd, 0X0800) when i send this it gives a error of send data in len[0,255] than how to send 14 bit data in this instruction Aug 1, 2021 at 11:40
  • You need to read the documentation for spi_open.
    – joan
    Aug 1, 2021 at 11:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.