Page 1 of 1
How to communicate with 40 bit SPI
Posted: Tue Nov 06, 2018 9:19 am
by Meekdai
pyb SPI bits can be 8 or 16, but TMC5130-TA is use 40 bit SPI. Does Pyboard have a way to communicate with this chip?
datasheet:
https://www.trinamic.com/fileadmin/asse ... ev1.15.pdf
Chapter 4 on page 21, description of SPI
Thanks
Re: How to communicate with 40 bit SPI
Posted: Tue Nov 06, 2018 10:02 am
by loboris
Just sent 5 bytes (= 40 bits).
Re: How to communicate with 40 bit SPI
Posted: Wed Nov 07, 2018 8:59 am
by Meekdai
Here is my code, but it doesn't works.
Code: Select all
def writeReg(self,regaddr,data):
self.tmc_cs.low()
self.spi.send(regaddr|0x80)
self.spi.send(0xFF & (data>>24))
self.spi.send(0xFF & (data>>16))
self.spi.send(0xFF & (data>>8))
self.spi.send(0xFF & (data>>0))
self.tmc_cs.high()
Re: How to communicate with 40 bit SPI
Posted: Wed Nov 07, 2018 9:39 am
by loboris
Pack your regaddr and data to one 5-byte bytearray and send it in one SPI transaction.
Re: How to communicate with 40 bit SPI
Posted: Thu Nov 08, 2018 1:58 am
by Meekdai
Code: Select all
def writeReg(self,regaddr,data):
self.tmc_cs.low()
ba=bytes([regaddr|0x80,0xFF&(data>>24),0xFF&(data>>16),0xFF&(data>>8),0xFF&data])
reg_val=self.spi.send_recv(ba)
self.tmc_cs.high()
self.reg_status=reg_val[0]>>32
return reg_val
It works well , thanks !