 |
DTR電平置低(-3--12V),復位 RTS置高(+3-+12V),選擇進入BootLoader ...延時100毫秒 DTR電平變高(+3-+12V)釋放復位 RTS維持高 開始連接...5, 接收到:79 1F 在串口COM6連接成功@115200bps,耗時795毫秒 晶片內BootLoader版本號:3.1 晶片PID:00000419 STM32F4xxx_43xx 讀出的選項字節: EFAA1055EFAA1055FF3F00C0FF3F00C0 開始全片擦除(全片擦除時間會比較長,請耐心等候!) 全片擦除成功 開始去除防寫 去除防寫成功 DTR電平置低(-3--12V),復位 RTS置高(+3-+12V),選擇進入BootLoader ...延時100毫秒 DTR電平變高(+3-+12V)釋放復位 RTS維持高 開始連接...5, 接收到:79 1F 在串口COM6連接成功@115200bps,耗時842毫秒 晶片內BootLoader版本號:3.1 晶片PID:00000419 STM32F4xxx_43xx 讀出的選項字節: EFAA1055EFAA1055FF3F00C0FF3F00C0 第889毫秒,已準備好 共寫入679KB,進度100%,耗時280193毫秒 寫入選項字節: FF AA 00 55 FF AA 00 55 FF FF 00 00 FF FF 00 00 成功寫入選項字節 寫入的選項字節: FFAA0055FFAA0055FFFF0000FFFF0000 從08000000開始運行失敗...可能是因為剛寫了選項字節!!! www.mcuisp.com(全脫機手持編程器EP968,全球首創)向您報告,命令執行完畢,一切正常
|
 |
|
 |
讀器件信息: 
|
 |
現在,我正在嘗試點亮LED燈。
|
 |
【程序】 #include "stm32f4xx.h"
void SystemInit(void) { }
int main(void) { RCC_AHB1ENR |= (1 << 7); GPIOH_MODER &= ~(0x03 << (2 * 10)); GPIOH_MODER |= (1 << 2 * 10); GPIOH_OTYPER &= ~(1 << 1 * 10); GPIOH_OTYPER |= (0 << 1 * 10); GPIOH_OSPEEDR &= ~(0x03 << 2 * 10); GPIOH_OSPEEDR |= (0 << 2 * 10); GPIOH_PUPDR &= ~(0x03 << 2 * 10); GPIOH_PUPDR |= (1 << 2 * 10); GPIOH_BSSR |= (1 << 16 << 10); while (1); return 0; }
|
 |
可見,STM32點亮LED要比C51和AVR複雜很多倍。
|
 |
【編譯錯誤】 *** Using Compiler 'V5.06 update 1 (build 61)', folder: 'C:\Keil_v5\ARM\ARMCC\Bin' Build target 'Target 1' compiling led.c... C:\Keil_v5\ARM\PACK\Keil\STM32F4xx_DFP\2.7.0\Drivers\CMSIS\Device\ST\STM32F4xx\Include\stm32f429xx.h(192): error: #5: cannot open source input file "core_cm4.h": No such file or directory #include "core_cm4.h" /* Cortex-M4 processor and core peripherals */ led.c: 0 warnings, 1 error ".\Objects\led.axf" - 1 Error(s), 0 Warning(s). Target not created. Build Time Elapsed: 00:00:14
|
 |
*** Using Compiler 'V5.06 update 1 (build 61)', folder: 'C:\Keil_v5\ARM\ARMCC\Bin' Build target 'Target 1' compiling led.c... led.c(9): error: #20: identifier "RCC_AHB1ENR" is undefined RCC_AHB1ENR |= (1 << 7); led.c(11): error: #20: identifier "GPIOH_MODER" is undefined GPIOH_MODER &= ~(0x03 << (2 * 10)); led.c(14): error: #20: identifier "GPIOH_OTYPER" is undefined GPIOH_OTYPER &= ~(1 << 1 * 10); led.c(17): error: #20: identifier "GPIOH_OSPEEDR" is undefined GPIOH_OSPEEDR &= ~(0x03 << 2 * 10); led.c(20): error: #20: identifier "GPIOH_PUPDR" is undefined GPIOH_PUPDR &= ~(0x03 << 2 * 10); led.c(23): error: #20: identifier "GPIOH_BSSR" is undefined GPIOH_BSSR |= (1 << 16 << 10); led.c(26): warning: #111-D: statement is unreachable return 0; led.c(27): warning: #1-D: last line of file ends without a newline } led.c: 2 warnings, 6 errors ".\Objects\led.axf" - 6 Error(s), 2 Warning(s). Target not created. Build Time Elapsed: 00:00:01
|
 |
#include "stm32f4xx.h"
//#define PERIPH_BASE ((unsigned int)0x40000000) #define AHB1PERIPH_BASE (PERIPH_BASE + 0x00020000) #define GPIOH_BASE (AHB1PERIPH_BASE + 0x1C00) #define GPIOH_MODER *(unsigned int*)(GPIOH_BASE+0x00) #define GPIOH_OTYPER *(unsigned int*)(GPIOH_BASE+0x04) #define GPIOH_OSPEEDR *(unsigned int*)(GPIOH_BASE+0x08) #define GPIOH_PUPDR *(unsigned int*)(GPIOH_BASE+0x0C) #define GPIOH_IDR *(unsigned int*)(GPIOH_BASE+0x10) #define GPIOH_ODR *(unsigned int*)(GPIOH_BASE+0x14) #define GPIOH_BSRR *(unsigned int*)(GPIOH_BASE+0x18) #define GPIOH_LCKR *(unsigned int*)(GPIOH_BASE+0x1C) #define GPIOH_AFRL *(unsigned int*)(GPIOH_BASE+0x20) #define GPIOH_AFRH *(unsigned int*)(GPIOH_BASE+0x24) #define RCC_BASE (AHB1PERIPH_BASE + 0x3800) #define RCC_AHB1ENR *(unsigned int*)(RCC_BASE+0x30)
void SystemInit(void) { }
int main(void) { RCC_AHB1ENR |= (1 << 7); GPIOH_MODER &= ~(0x03 << (2 * 10)); GPIOH_MODER |= (1 << 2 * 10); GPIOH_OTYPER &= ~(1 << 1 * 10); GPIOH_OTYPER |= (0 << 1 * 10); GPIOH_OSPEEDR &= ~(0x03 << 2 * 10); GPIOH_OSPEEDR |= (0 << 2 * 10); GPIOH_PUPDR &= ~(0x03 << 2 * 10); GPIOH_PUPDR |= (1 << 2 * 10); GPIOH_BSRR |= (1 << 16 << 10); while (1); }
|
 |
10樓
巨大八爪鱼
2016-3-24 23:26
*** Using Compiler 'V5.06 update 1 (build 61)', folder: 'C:\Keil_v5\ARM\ARMCC\Bin' Build target 'Target 1' compiling led.c... linking... Program Size: Code=244 RO-data=444 RW-data=0 ZI-data=1024 FromELF: creating hex file... ".\Objects\led.axf" - 0 Error(s), 0 Warning(s). Build Time Elapsed: 00:00:01
|