[SOLVED] SPI send problem

General discussions and questions abound development of code with MicroPython that is not hardware specific.
Target audience: MicroPython Users.
Post Reply
ajie_dirgantara
Posts: 81
Joined: Fri Sep 02, 2016 9:26 am

[SOLVED] SPI send problem

Post by ajie_dirgantara » Tue Sep 05, 2017 8:24 am

I've done :

Code: Select all

spi = pyb.SPI(2, pyb.SPI.MASTER, prescaler = 2, polarity = 0, phase = 0, bits = 8) 
buf=bytearray(3)
buf[0]=0x01
buf[1]=0x02
buf[2]=0x03
spi.send(buf[0])
spi.send(buf[1])
spi.send(buf[2])
but why is that the result in logic analyzer is different from :

Code: Select all

spi = pyb.SPI(2, pyb.SPI.MASTER, prescaler = 2, polarity = 0, phase = 0, bits = 8) 
buf=bytearray(3)
buf[0]=0x01
buf[1]=0x02
buf[2]=0x03
spi.send(buf)
in the second code, there are some additional clock on SCK pin, so the byte sequence is 0x00,0x00,0x00,0x01,0x02,0x03 instead of just 0x01,0x02,0x03

the logic should be equal right?
Last edited by ajie_dirgantara on Tue Oct 03, 2017 7:13 am, edited 2 times in total.

ajie_dirgantara
Posts: 81
Joined: Fri Sep 02, 2016 9:26 am

(SOLVED) Re: SPI send problem

Post by ajie_dirgantara » Tue Sep 05, 2017 9:31 am

ok, the problem solved by adding spi.deinit() everytime I want to do spi.recv()

Post Reply