QT PY SAMD hardware spi pins

Please tell us which board you are using.
For CircuitPython issues, ask in the Adafruit CircuitPython forum.

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
davidkjackson
 
Posts: 20
Joined: Thu Apr 20, 2023 10:27 pm

QT PY SAMD hardware spi pins

Post by davidkjackson »

I am doing something really dumb but cannot see what.
Using the Color OLED (part 1431) connected to the breakout board (5613) and that is connected to the QT PY SAMD.
I am trying to run the example test program from the SSD1331 library.

I have these pins defined as per the QT PY:
/

Code: Select all

/
// Screen dimensions
#define SCREEN_WIDTH  128
#define SCREEN_HEIGHT 128
#define SCLK_PIN 8                           
#define MOSI_PIN 10
#define DC_PIN   7
#define CS_PIN   6
#define RST_PIN  1
The code then allows either software defined pins or hardware SPI pins
/

Code: Select all

/ Option 1: use any pins but a little slower
Adafruit_SSD1351 tft = Adafruit_SSD1351(SCREEN_WIDTH, SCREEN_HEIGHT, CS_PIN, DC_PIN, MOSI_PIN, SCLK_PIN, RST_PIN);  

Code: Select all

// Option 2: must use the hardware SPI pins 
//Adafruit_SSD1351 tft = Adafruit_SSD1351(SCREEN_WIDTH, SCREEN_HEIGHT, &SPI, CS_PIN, DC_PIN, RST_PIN);
The first method works perfectly but if I comment out the first and enable the second I then get an entirely pixelated garbage screen displayed).
I am clearly missing something obvious!

User avatar
adafruit_support_carter
 
Posts: 29457
Joined: Tue Nov 29, 2016 2:45 pm

Re: QT PY SAMD hardware spi pins

Post by adafruit_support_carter »

Is this the QT PY being used?
https://www.adafruit.com/product/4600

Are all of your libraries and board supports up to date?

User avatar
davidkjackson
 
Posts: 20
Joined: Thu Apr 20, 2023 10:27 pm

Re: QT PY SAMD hardware spi pins

Post by davidkjackson »

Hi -
yes that is the correct Qt Py and yes all
Libraries are up to date and current as I only installed all this yesterday .
It works fine using the software pins but not when I change to calling the function and have it use the same pins but only calling with the 3 pin parameters .

User avatar
adafruit_support_carter
 
Posts: 29457
Joined: Tue Nov 29, 2016 2:45 pm

Re: QT PY SAMD hardware spi pins

Post by adafruit_support_carter »

Weird. Nothing obvious. Those *should* be the same pins:
https://learn.adafruit.com/adafruit-qt-py/pinouts

Another simple thing to check - what board are you selecting in the Arduino IDE? Tools -> Boards = ?

User avatar
davidkjackson
 
Posts: 20
Joined: Thu Apr 20, 2023 10:27 pm

Re: QT PY SAMD hardware spi pins

Post by davidkjackson »

Hi,
Using the Adafruit QT PY M0(SAMD21) board
I have uninstalled the prereqs and reinstalled but no change.

User avatar
adafruit2
 
Posts: 22187
Joined: Fri Mar 11, 2005 7:36 pm

Re: QT PY SAMD hardware spi pins

Post by adafruit2 »

can you try and go into this file in your libraries folder and change this number to 8000000 (8MHz not 24MHz)?
https://github.com/adafruit/Adafruit-SS ... 51.cpp#L58

User avatar
davidkjackson
 
Posts: 20
Joined: Thu Apr 20, 2023 10:27 pm

Re: QT PY SAMD hardware spi pins

Post by davidkjackson »

Good spot!
That has fixed the issue. :-)
Can't believe nobody had hit this previously!

Will you issue a formal fix?

User avatar
davidkjackson
 
Posts: 20
Joined: Thu Apr 20, 2023 10:27 pm

Re: QT PY SAMD hardware spi pins

Post by davidkjackson »

Just a little bit more on this.
As well as the 8Mhz that you asked me to change to, I tried 12mhz and 16Mhz.
16 fails.
12 works OK.
So, it appears that the maximum for the QT PY SAMD21 would be 12Mhz. I am not sure what the official value should be and not sure where to go look for that.
For now, I have stuck with the value of 8Mhz that you suggested.

User avatar
davidkjackson
 
Posts: 20
Joined: Thu Apr 20, 2023 10:27 pm

Re: QT PY SAMD hardware spi pins

Post by davidkjackson »

The Adafruit_SSD1351.cpp file contains:

Code: Select all

// TODO: this will be moved to SPITFT, but for now:
#if defined(ARDUINO_ARCH_ARC32)
#define SPI_DEFAULT_FREQ 16000000 ///< ARC32 SPI default frequency
#elif defined(__AVR__) || defined(TEENSYDUINO)
#define SPI_DEFAULT_FREQ 8000000 ///< AVR SPI default frequency
##elif defined(__SAMD51__)
#define SPI_DEFAULT_FREQ 12000000 ///< M4 SPI default frequency
#elif defined(ARDUINO_SAMD_ZERO)
#define SPI_DEFAULT_FREQ 12000000 ///< M0 SPI default frequency
#elif defined(ESP8266) || defined(ARDUINO_MAXIM)
#define SPI_DEFAULT_FREQ 16000000 ///< ESP8266 SPI default frequency
#elif defined(__SAM3X8E__)
#define SPI_DEFAULT_FREQ 20000000 ///< SAM3X (ARDUINO DUE) SPI default frequency
#elif defined(ESP32)
#define SPI_DEFAULT_FREQ 16000000 ///< ESP32 SPI default frequency
#elif defined(RASPI)
#define SPI_DEFAULT_FREQ 24000000 ///< RASPI SPI default frequency
#elif defined(ARDUINO_NRF52840_FEATHER)
#define SPI_DEFAULT_FREQ 16000000 ///< NRF52840 SPI default frequency
#else
#define SPI_DEFAULT_FREQ 24000000 ///< SPI default frequency
#endif
There is a specific check for __SAMD51__ but there is no check for SAMD21.
Adding that is probably a better solution that changing the last line default from 24000000 .
What is the preprocessor definition value for a QT PY SAMD21? It doesn't appear to be __SAMD21__ and I do not know where to go look for what the preprocessor directive is.

User avatar
adafruit_support_carter
 
Posts: 29457
Joined: Tue Nov 29, 2016 2:45 pm

Re: QT PY SAMD hardware spi pins

Post by adafruit_support_carter »

That code block has been removed in favor of a simple, single 8MHz default.
https://github.com/adafruit/Adafruit-SS ... ry/pull/38

User avatar
davidkjackson
 
Posts: 20
Joined: Thu Apr 20, 2023 10:27 pm

Re: QT PY SAMD hardware spi pins

Post by davidkjackson »

Hi, can you tell me if the fix is planned to be published and made available in a new build any time soon? Many thanks

User avatar
adafruit_support_carter
 
Posts: 29457
Joined: Tue Nov 29, 2016 2:45 pm

Re: QT PY SAMD hardware spi pins

Post by adafruit_support_carter »

Just bumped and released. Look for 1.3.0 to show up in Arduino Library Manager:
https://github.com/adafruit/Adafruit-SS ... /tag/1.3.0

User avatar
davidkjackson
 
Posts: 20
Joined: Thu Apr 20, 2023 10:27 pm

Re: QT PY SAMD hardware spi pins

Post by davidkjackson »

Many thanks for the quick reply. I just picked up the 1.3.0 update.

Locked
Please be positive and constructive with your questions and comments.

Return to “Itsy Bitsy Boards”