MDK-ARM - Lチカコードをかく。
- 左のプロジェクトから、main.cを開く。(Project: Test01 -> Test01 Configuration -> Application/User)
- 下にスクロールしていくと、
int main(void)
が現れ、 その中にwhile (1)
が出てくる。 - 下のように、コードを記述。(
/* USER CODE BEGIN 3 */
から/* USER CODE END 3 */
の間にユーザコードを書くといいんだろう。)
main.c
...
/* Infinite loop */
/* USER CODE BEGIN WHILE */
while (1)
{
/* USER CODE END WHILE */
/* USER CODE BEGIN 3 */
#define LED_GPIO_PORT GPIOB
#define LED_GREEN_GPIO_PIN GPIO_PIN_7
#define LED_BLUE_GPIO_PIN GPIO_PIN_6
HAL_GPIO_WritePin(LED_GPIO_PORT, LED_GREEN_GPIO_PIN, GPIO_PIN_SET);
HAL_Delay(125);
HAL_GPIO_WritePin(LED_GPIO_PORT, LED_GREEN_GPIO_PIN, GPIO_PIN_RESET);
HAL_Delay(125);
}
/* USER CODE END 3 */
}
...
Build、Burn, Debug Run
-
Project -> Build target (F7)
-
Flash -> Download (Erase => Program -> Verify ってのがステータスバーに現れる)
-
Debug ->
Start/Stop Debug Session (Ctrl+F5)
# Evaluationだよ、ってDialogで、[OK]
-
mainの一行目で、Breakしてとまる。
-
Debug->Run(F5) で実行 => ボードの緑のLEDがちかちかする。
-
# ショートカットキー
Run(F5), Step(F11), Step Over(F10), Step Out(Ctrl+F11), Run to Cursor Line(Ctrl+F10)
build.log
Build target 'Test01 Configuration'
compiling system_stm32l1xx.c...
assembling startup_stm32l152xc.s...
compiling stm32l1xx_hal_lcd.c...
compiling stm32l1xx_hal_flash_ex.c...
compiling stm32l1xx_hal_pwr.c...
compiling stm32l1xx_hal_flash_ramfunc.c...
compiling stm32l1xx_hal_dma.c...
compiling stm32l1xx_hal.c...
compiling stm32l1xx_hal_rcc_ex.c...
compiling stm32l1xx_hal_rcc.c...
compiling stm32l1xx_hal_flash.c...
compiling stm32l1xx_hal_adc_ex.c...
compiling stm32l1xx_hal_cortex.c...
compiling stm32l1xx_hal_gpio.c...
compiling stm32l1xx_hal_adc.c...
compiling stm32l1xx_hal_pwr_ex.c...
compiling main.c...
compiling stm32l1xx_it.c...
compiling stm32l1xx_hal_msp.c...
linking...
Program Size: Code=7236 RO-data=356 RW-data=36 ZI-data=1156
FromELF: creating hex file...
"Test01 Configuration\Test01 Configuration.axf" - 0 Error(s), 0 Warning(s).
Build Time Elapsed: 00:00:06