Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RP2350: SPI with DMA seems not working #4690

Open
advancedlogic opened this issue Jan 6, 2025 · 1 comment
Open

RP2350: SPI with DMA seems not working #4690

advancedlogic opened this issue Jan 6, 2025 · 1 comment
Labels

Comments

@advancedlogic
Copy link

First of all, thanks for the amazing effort to develop TinyGo.
I am creating a library to experiment with the Geeek Pico Breadboard https://github.com/geeekpi/pico_breadboard_kit using the RP PICO 2 (RP2350).

  • NeoPixel: OK
  • Joystick: OK
  • Leds: OK
  • Buzzer (Speaker): KO, PWM seems not yet available for RP PICO 2
  • Display (ST7796U): OK but without DMA
  • Touch: Not implemented yet

I was able to modify the driver ST7789 to work with the ST7796U (480x320) but if I try to use the method Tx(w,r []byte) with more than 1 byte, the PICO 2 freezes during the initialization process and I did not find a way to understand why. Everything works if I send each byte using Transfer (but it's slow for a decent refresh rate). - https://github.com/tinygo-org/tinygo/blob/release/src/machine/machine_rp2_spi.go

I also tried with an ST7789 using the driver available https://github.com/tinygo-org/drivers/tree/release/st7789, with the RP PICO 2 and it freezes during the initialization process.

It seems related to the DMA access. In the RP2350 Datasheet it seems that for payloads less than 250MB it should be retro-compatible with RP2040 but the DMA SPI addresses seem different. I maybe wrong (I am not an expert in microcontrollers)

@advancedlogic
Copy link
Author

I don't think the behavior is supposed to be this one, but I managed to make it work, transferring 4 Bytes at the time:

func (d *DeviceOf[T]) sendCommand(command uint8) error {
	d.dcPin.Low()
	d.csPin.Low()
	err := d.bus.Tx([]byte{command}, nil)
	d.csPin.High()
	return err
}

func (d *DeviceOf[T]) sendData(data []byte) error {
	d.dcPin.High()
	d.csPin.Low()
	for i := 0; i < len(data); i += 4 {
		end := i + 4
		if end > len(data) {
			end = len(data)
		}
		if err := d.bus.Tx(data[i:end], nil); err != nil {
			return err
		}
	}
	d.csPin.High()
	return nil
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants