stm32duino / Arduino_Core_STM32

STM32 core support for Arduino
https://github.com/stm32duino/Arduino_Core_STM32/wiki
Other
2.86k stars 979 forks source link

STM32F103RCT6 #1234

Closed EG-bit closed 4 years ago

EG-bit commented 4 years ago

Hello, sorry for the trouble. I ran into a problem, it is not possible to correctly flash the microcontroller, that is, I configure the outputs and set it to a low state and the PD1 output is always set to the high level. When I set other outputs to the upper level, then nothing changes. When flashing through CubeIDE, everything is correctly stitched. Help please, I'm not good at programming, I'm just learning.

IMG_20201106_105703 IMG_20201106_105738

My test code:

#define R1    PA8
#define R2    PC8
#define R3    PC7
#define R4    PC6
#define R5    PB15
#define R6    PB14
#define R7    PB13
#define R8    PB12
#define R9    PD1
#define R10   PD0
#define R11   PC13
#define R12   PB9
#define R13   PB8
#define R14   PB4
#define R15   PB3
#define R16   PA15

const bool Relays[] = {R1,R2,R3,R4,R5,R6,R7,R8,R9,R10,R11,R12,R13,R14,R15,R16};

void setup() {

  for(int a = 0; a < 16; a++){
   pinMode(Relays[a], OUTPUT);
   digitalWrite(Relays[a], 0); 
  }
digitalWrite(R1, HIGH);  //Relay test
}

void loop() {
  // put your main code here, to run repeatedly:

}
fpistm commented 4 years ago

Before flash you should be able to compile...

sketch_nov06a:5:32: error: narrowing conversion of '7' from 'int' to 'bool' [-Wnarrowing]
    5 | const bool Relays[] = {R1,R2,R3};
      |                                ^
sketch_nov06a:5:32: error: narrowing conversion of '6' from 'int' to 'bool' [-Wnarrowing]
sketch_nov06a:5:32: error: narrowing conversion of '5' from 'int' to 'bool' [-Wnarrowing]
#define R1    PA8
#define R2    PB10
#define R3    PB4

const uint32_t Relays[] = {R1, R2, R3};

void setup() {

  for (int a = 0; a < 3; a++) {
    pinMode(Relays[a], OUTPUT);
    digitalWrite(Relays[a], 0);
  }
  digitalWrite(R1, HIGH);  //Relay test
}

void loop() {
  // put your main code here, to run repeatedly:

}

If it compile, maybe you not used this core.