本帖最后由 原来的你 于 2017-5-14 12:10 编辑
转眼很长时间过去了,由于NUCLEO-L496ZG借给网友做开发新产品开发评估,所以一直没有开发评测NUCLEO-L496ZG,今天抽空先初次体验一下NUCLEO-L496ZG,后面再给出更多享。本人一直喜欢MCU跑操作系统,目前来说可用的操作系统很多,本次选择RTX来作为NUCLEO-L496ZG系统平台。首先当然我们需要下载NUCLEO-L496ZG的支持包,en.stm32cubel4\STM32Cube_FW_L4_V1.8.0,本次我们选择en.stm32cubel4\STM32Cube_FW_L4_V1.8.0\Projects\STM32L496ZG-Nucleo\Examples\GPIO\GPIO_IOToggle作为我们的demo板。
打开工程如下,
添加RTX 系统的配置文件, 配置文件在MDK的安装目录Keil_v5\ARM\RL\RTX\Config下面,文件名为 RTX_Conf_CM.c,将这个文件复制到 MDK 工程的en.stm32cubel4\STM32Cube_FW_L4_V1.8.0\Projects\STM32L496ZG-Nucleo\Examples\GPIO\GPIO_IOToggle\Src 文件夹下面,并添加到MDK 工程上
通过上面两步,RTX 操作系统的移植就完成,就是这么简单。下面如图所示就是RTX配置,根据需要进行配置。
运行程序如下: - int main(void)
- {
- /* This sample code shows how to use GPIO HAL API to toggle LED1 and LED2 IOs
- in an infinite loop. */
- /* STM32L4xx HAL library initialization:
- - Configure the Flash prefetch
- - 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
- */
- HAL_Init();
- /* Configure the system clock to 80 MHz */
- SystemClock_Config();
-
- /* -1- Enable GPIO Clock (to be able to program the configuration registers) */
- LED1_GPIO_CLK_ENABLE();
- LED2_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_PULLUP;
- GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
- GPIO_InitStruct.Pin = LED1_PIN;
- HAL_GPIO_Init(LED1_GPIO_PORT, &GPIO_InitStruct);
- GPIO_InitStruct.Pin = LED2_PIN;
- HAL_GPIO_Init(LED2_GPIO_PORT, &GPIO_InitStruct);
-
- os_sys_init_user (AppTaskStart, 2,&AppTaskStartStk, sizeof(AppTaskStartStk));
-
- while(1);
- }
复制代码- static void AppTaskCreate (void);
- __task void AppTaskLED(void);
- __task void AppTaskStart(void);
- static uint64_t AppTaskLEDStk[512/8]; /* 任务栈 */
- static uint64_t AppTaskStartStk[512/8]; /* 任务栈 */
- /* 任务句柄 */
- OS_TID HandleTaskLED = NULL;
- __task void AppTaskStart(void)
- {
- AppTaskCreate();
- while(1)
- {
- HAL_GPIO_TogglePin(LED1_GPIO_PORT, LED1_PIN);
- os_dly_wait(500);
- }
- }
- __task void AppTaskLED(void)
- {
- while(1)
- {
- HAL_GPIO_TogglePin(LED2_GPIO_PORT, LED2_PIN);
- os_dly_wait(500);
- }
- }
复制代码- static void AppTaskCreate (void)
- {
- HandleTaskLED = os_tsk_create_user(AppTaskLED, 1, &AppTaskLEDStk, sizeof(AppTaskLEDStk));
- }
复制代码
|