收到板子后,发现识别不到目标芯片。
配套文档
mb2032-wb09-b02-schematic.pdf
(7.78 MB, 下载次数: 1)
nucleo-wb09ke.pdf
(501.05 KB, 下载次数: 0)
跟网友交流后,怀疑是小板问题,通过万用表检测,发现是CN1的1和2引脚短路所致。对插座进行维修,大头针撬开,发现了短路的**,分离后,重新插入,已经可以检测到目标芯片了。
下载相关资源,在KEIL安装相关pack包。
点灯就是GPIO的翻转操作,所以找到示例目录
\STM32Cube_FW_WB0_V1.0.0\Projects\NUCLEO-WB09KE\Examples\GPIO\GPIO_IOToggle
打开MDK-ARM文件夹,启动工程(前提你已经安装了相关pack)
示例中仅使用了2颗LED,这里我们把3颗用户可编程LED都用上,显得炫酷。蓝色、绿色、红色
完善主函数代码如下
- int main(void)
- {
- /* USER CODE BEGIN 1 */
- /* STM32WB0x HAL library initialization:
- - Systick timer is configured by default as source of time base, but user
- can eventually implement his proper time base source (a general purpose
- timer for example or other time source), keeping in mind that Time base
- duration should be kept 1ms since PPP_TIMEOUT_VALUEs are defined and
- handled in milliseconds basis.
- - Set NVIC Group Priority to 4
- - Low Level Initialization
- */
- /* USER CODE END 1 */
- /* MCU Configuration--------------------------------------------------------*/
- /* Reset of all peripherals, Initializes the Flash interface and the Systick. */
- HAL_Init();
- /* USER CODE BEGIN Init */
- /* USER CODE END Init */
- /* Configure the system clock */
- SystemClock_Config();
- /* Configure the peripherals common clocks */
- PeriphCommonClock_Config();
- /* USER CODE BEGIN SysInit */
- /* USER CODE END SysInit */
- /* Initialize all configured peripherals */
- MX_GPIO_Init();
- /* USER CODE BEGIN 2 */
- /* -1- Enable GPIO Clock (to be able to program the configuration registers) */
- LD1_GPIO_CLK_ENABLE();
- LD2_GPIO_CLK_ENABLE();
- LD3_GPIO_CLK_ENABLE();
- /* -2- Configure IO in output push-pull mode to drive external LEDs */
- GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
- GPIO_InitStruct.Pull = GPIO_NOPULL;
- GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
- GPIO_InitStruct.Pin = LD1_PIN;
- HAL_GPIO_Init(LD1_GPIO_PORT, &GPIO_InitStruct);
- GPIO_InitStruct.Pin = LD2_PIN;
- HAL_GPIO_Init(LD2_GPIO_PORT, &GPIO_InitStruct);
- GPIO_InitStruct.Pin = LD3_PIN;
- HAL_GPIO_Init(LD3_GPIO_PORT, &GPIO_InitStruct);
-
- /* USER CODE END 2 */
- /* Infinite loop */
- /* USER CODE BEGIN WHILE */
- while (1)
- {
- /* USER CODE END WHILE */
- /* USER CODE BEGIN 3 */
- HAL_GPIO_TogglePin(LD1_GPIO_PORT, LD1_PIN);
- /* Insert delay 100 ms */
- HAL_Delay(100);
- HAL_GPIO_TogglePin(LD2_GPIO_PORT, LD2_PIN);
- /* Insert delay 100 ms */
- HAL_Delay(100);
- HAL_GPIO_TogglePin(LD3_GPIO_PORT, LD3_PIN);
- /* Insert delay 100 ms */
- HAL_Delay(100);
- }
- /* USER CODE END 3 */
- }
编译,并下载程序,完美。
- Build Time Elapsed: 00:00:01
- Load "GPIO_IOToggle\\GPIO_IOToggle.axf"
- Erase Done.
- Programming Done.
- Verify OK.
- Flash Load finished at 12:31:02
这个时候就看到蓝绿红三颗LED从左到右滚动点亮了。
|