things to note : if i use regular hw SPI constructor with default MOSI SCK pins screen works perfectly fine. i only move those two pins to sercom SPI but screen is just blank. while wired for sercom SPI i changed the constructor to use software SPI again screen works with those pins intended for sercom SPI. like this;
Adafruit_ST7735 tft = Adafruit_ST7735(TFT_CS, TFT_DC, TFT_MOSI, TFT_SCLK, TFT_RST);
along with
#define TFT_MOSI 11
#define TFT_SCLK 12
if i keep the code above for softwareSPI and also keep the sercom declaration along with pinperipheral for pins 11 and 12 screen still works in software SPI. while all this is happening i get very fast count from 1 to 255 in serial monitor which i believe is a sign at least mySPI is alive.
can anybody please look at the code and see if im doing something wrong. thank you
Code: Select all
#include <Adafruit_GFX.h>
#include <Adafruit_ST7735.h>
#include <SPI.h>
#include "wiring_private.h" //essential for pinperipheral function
#define TFT_CS 6
#define TFT_RST 9
#define TFT_DC 10
SPIClass mySPI (&sercom1, 13, 12, 11, SPI_PAD_0_SCK_3, SERCOM_RX_PAD_1); // sercom spi definition
Adafruit_ST7735 tft = Adafruit_ST7735(&mySPI, TFT_CS, TFT_DC, TFT_RST); // st7735 constructor
void setup() {
Serial.begin(115200);
mySPI.begin();
pinPeripheral(11, PIO_SERCOM); //defining pin 11, 12, 13 to be used as sercom pins.
pinPeripheral(12, PIO_SERCOM);
pinPeripheral(13, PIO_SERCOM);
tft.initR(INITR_MINI160x80);
tft.fillScreen(ST7735_WHITE);
tft.setTextWrap(false);
tft.setCursor(0, 0);
tft.setTextColor(ST7735_BLACK);
tft.setTextSize(3);
tft.println("Hello");
}
uint8_t i=0;
void loop()
{
Serial.println(i);
mySPI.beginTransaction(SPISettings(8000000, MSBFIRST, SPI_MODE0)); // copied this part from adafruit spi example
mySPI.transfer(i++);
mySPI.endTransaction();
}