Page 1 of 1

SPI hardware

Posted: Wed Jun 05, 2019 6:45 pm
by monk65
hello,

i use the spi in mode hardware , so i must configure the pin cs on the pin 15 as a chip select , but unfortunately my transfer don't work

hspi.init(baudrate=400000,sck=Pin(14), mosi=Pin(13), miso=Pin(12),firstbit=SPI.MSB )
cs.off()
hspi.write_readinto(b'\xE0\x00\x00\x00\x00\x00\x00\x00',buf)
cs.on()

but when i make the same function with Arduino C++, it works !
digitalWrite(m_ss, LOW);
m_spi.beginTransaction(SPISettings(400000, SPI_MSBFIRST, SPI_MODE0));
m_spi.transferBytes(const_cast<uint8_t*>(req.data()), resp.data(), req.size());
digitalWrite(m_ss, HIGH);


i don-t understand the problem :?

Re: SPI hardware

Posted: Wed Jun 05, 2019 8:44 pm
by OutoftheBOTS_
I am not sure what port of MP your using but check if the CS pin is going low or not as the main supported method for pin control is cs.value(0) or cs.value(1)

Re: SPI hardware

Posted: Thu Jun 06, 2019 10:10 am
by jimmo
Also check that the cs pin is initialized with Pin.OUT.

Re: SPI hardware

Posted: Thu Jun 13, 2019 7:36 pm
by monk65
yes it is initialise and i checked with a analyser logic, it's strange
cs = Pin(15, Pin.OUT)
some parameters are not accsessible (dma channel)

With Arduino IDE, my peripheral answer to the transfert

I don't see any example in micropython except
fork
https://github.com/loboris/MicroPython_ ... o/wiki/spi

but arguments are different !

Re: SPI hardware

Posted: Thu Jun 13, 2019 10:08 pm
by jimmo
What do you see on the analyser? Do you see your data going out? Is the problem that you never get a result stored in buf? (How is buf initialised?)

Re: SPI hardware

Posted: Sun Aug 11, 2019 3:38 pm
by monk65
i found my problem, my fpga was a response with decoded specific
thank for your reply, i finish this work, and micropython is a wonderful
programmation language
here's the simple code , i like this syntax , very clean

buf= bytearray(size)
self.hspi.init(baudrate=400000,sck=Pin(14), mosi=Pin(13), miso=Pin(12),firstbit=SPI.MSB ) # set the baudrate*
self.cs.off()
self.hspi.write_readinto(cmd,buf)
self.cs.on()


i close this post