본문 바로가기

[ST_MICRO]/STM32F103-SM

[STM32-48 SSM EVM] STM32F103 Arduino 만들기


Arduino Board 파일은 https://github.com/stm32duino/Arduino_Core_STM32 를 사용한다.

먼저 Arduino 

https://github.com/stm32duino/BoardManagerFiles/raw/main/package_stmicroelectronics_index.json

 

Arduino Boards Manager 에서 Genernic STM32F1 Series를 선택한다.

 

 

Board part number를 ELAB_STM32F1x_SSM 보드를 선택 한다.
Generic F1 보드파일을 수정해서 ELAB_STM32F1x_SSM보드파일로 만들었다.

// SPI definitions
#ifndef PIN_SPI_SS
  #define PIN_SPI_SS            PB10
#endif
#ifndef PIN_SPI_SS1
  #define PIN_SPI_SS1           PA15
#endif
#ifndef PIN_SPI_SS2
  #define PIN_SPI_SS2           PNUM_NOT_DEFINED
#endif
#ifndef PIN_SPI_SS3
  #define PIN_SPI_SS3           PNUM_NOT_DEFINED
#endif
#ifndef PIN_SPI_MOSI
  #define PIN_SPI_MOSI          PB15
#endif
#ifndef PIN_SPI_MISO
  #define PIN_SPI_MISO          PB14
#endif
#ifndef PIN_SPI_SCK
  #define PIN_SPI_SCK           PB13
#endif

// I2C definitions
#ifndef PIN_WIRE_SDA
  #define PIN_WIRE_SDA          PB9
#endif
#ifndef PIN_WIRE_SCL
  #define PIN_WIRE_SCL          PB8
#endif

// Timer Definitions
// Use TIM6/TIM7 when possible as servo and tone don't need GPIO output pin
#ifndef TIMER_TONE
  #define TIMER_TONE            TIM3
#endif
#ifndef TIMER_SERVO
  #define TIMER_SERVO           TIM4
#endif

// UART Definitions
#ifndef SERIAL_UART_INSTANCE
  #define SERIAL_UART_INSTANCE  2
#endif

// Default pin used for generic 'Serial' instance
// Mandatory for Firmata
#ifndef PIN_SERIAL_RX
  #define PIN_SERIAL_RX         PA10
#endif
#ifndef PIN_SERIAL_TX
  #define PIN_SERIAL_TX         PA9
#endif

[STM32F103-48 SSM] 보드의 기본 동작 테스트를 아래 코드로 스위치를 누를때 마다 LED가 깜박이는 것을 확인할 수 있다.

 

#define LED_PIN1        PB0
#define SW_PIN1        PB12


void setup() {
	pinMode(LED_PIN1, OUTPUT);
	pinMode(SW_PIN1, INPUT_PULLUP);

	Serial.begin(115200);
}

int cnt = 0;
int led_toggle = 0;

void loop() {
  
	if(digitalRead(SW_PIN1) == 0)
	{
		led_toggle ^= 1;
		digitalWrite(LED_PIN1, led_toggle);
		
		Serial.println(cnt++);
		delay(500);		
	}
}
반응형