Skip to content

Using SPI Class crash system #667

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

Closed
arnold-b opened this issue Sep 25, 2019 · 2 comments
Closed

Using SPI Class crash system #667

arnold-b opened this issue Sep 25, 2019 · 2 comments
Labels
answered question ❓ Usually converted as a discussion

Comments

@arnold-b
Copy link

arnold-b commented Sep 25, 2019

STM32F407VGT

Serial: PA9, PA10
SPI: PA7, PA6, PA5

Sample:

#define TFT_CS         PB4
SPIClass HWSPI = SPIClass(PA7,PA6,PA5,TFT_CS);
void setup() {
  Serial.begin(115200);
  Serial.println("Test!");
  pinMode(PB4, OUTPUT);
 HWSPI.begin(); //Initialize the SPI_1 port.
Serial.println("HWSPI");   // No output anymore
   }

void loop(void) {   
Serial.println("Loop IO");

delayMicroseconds(100); 
digitalWrite(PB4, HIGH);
HWSPI.transfer(0xb4);
digitalWrite(PB4, LOW);
}

Output Serial:
Test!

Thats it

@fpistm
Copy link
Member

fpistm commented Sep 25, 2019

Hi @arnold-b
That is normal as you don't follow SPI API.
https://github.com/stm32duino/wiki/wiki/API#spi

PB4 is not a hardware CS, so you should not give it to constructor:

#include "SPI.h"
#define TFT_CS         PB4

SPIClass HWSPI = SPIClass(PA7, PA6, PA5);

void setup() {
  Serial.begin(115200);
  Serial.println("Test!");
  pinMode(TFT_CS, OUTPUT);
  HWSPI.begin(); //Initialize the SPI_1 port.
  Serial.println("HWSPI");   // No output anymore
}

void loop(void) {
  Serial.println("Loop IO");
  delayMicroseconds(1000000);
  digitalWrite(TFT_CS, HIGH);
  HWSPI.transfer(0xb4);
  digitalWrite(TFT_CS, LOW);
}

@fpistm fpistm added question ❓ Usually converted as a discussion waiting feedback Further information is required labels Sep 25, 2019
@arnold-b
Copy link
Author

OK, thank you. I will test it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
answered question ❓ Usually converted as a discussion
Projects
None yet
Development

No branches or pull requests

2 participants