Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 3882

MicroPython • Re: SPI just Plain not working

$
0
0
I attached an LED to pin 18,

Baudrate at 1 won't work! I think that the minimum spi clock is 244Khz using a 125Mhz clock.

Rp2040 datasheet 4.4.3.6.1. Bit rate generation

B.T.W.
You mean pin number 24 GPIO18 right!
or use pin 25 GPIO19.


To see if it works using the led at 400K baud write different data and put the led on GPIO19 pin 25.

ex:

Code:

from machine import SPI,Pinfrom time import sleep_usspi = SPI(0, baudrate=400000, polarity=1, phase=1, bits=8, firstbit=SPI.MSB, sck=Pin(18), mosi=Pin(19), miso=Pin(16))print("test")while True:    for i in range(25000):        spi.write(b'\x00')        sleep_us(30)    for i in range(25000):        spi.write(b'\xF0')        sleep_us(30)    for i in range(25000):        spi.write(b'\xFF')        sleep_us(30)

Statistics: Posted by danjperron — Wed Jul 17, 2024 4:02 pm



Viewing all articles
Browse latest Browse all 3882

Trending Articles