NXP-MPC5748G车载MCU使用(食用)方法(踩坑)实用指南(骗人教程)(二):使用FREERTOS点亮LED

  1. 创建工程
  2. 对工程进行配置

选中主工程后。如图,点击processor expert→show views打开配置选板。在Components Library中选择FreeRTOS添加到工程
在这里插入图片描述

配置需要被点亮的lED。双击左侧的pin_mux:PinSettings,进行如下设置。选择需要被控制的LED
在这里插入图片描述
3. 代码

补全代码。代码共3个文件,如图
在这里插入图片描述

main.c

/*
 * Copyright (c) 2013 - 2015, Freescale Semiconductor, Inc.
 * Copyright 2016-2017 NXP
 * All rights reserved.
 *
 * THIS SOFTWARE IS PROVIDED BY NXP "AS IS" AND ANY EXPRESSED OR
 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
 * IN NO EVENT SHALL NXP OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
 * THE POSSIBILITY OF SUCH DAMAGE.
 */
/* ###################################################################
 **     Filename    : main.c
 **     Processor   : MPC574xG
 **     Abstract    :
 **         Main module.
 **         This module contains user's application code.
 **     Settings    :
 **     Contents    :
 **         No public methods
 **
 ** ###################################################################*/
/*!
 ** @file main.c
 ** @version 01.00
 ** @brief
 **         Main module.
 **         This module contains user's application code.
 */
/*!
 **  @addtogroup main_module main module documentation
 **  @{
 */
/* MODULE main */


/* Including necessary module. Cpu.h contains other modules needed for compiling.*/
#include "Cpu.h"

volatile int exit_code = 0;
/* User includes (#include below this line is not maintained by Processor Expert) */
#include <stdint.h>
#include <stdbool.h>
#include "task.h"
#include "externalFunctions.h"







/*! 
  \brief The main function for the project.
  \details The startup initialization sequence is the following:
 * - startup asm routine
 * - main()
 */
int main(void)
{
	/* Write your local variable definition here */

	/*** Processor Expert internal initialization. DON'T REMOVE THIS CODE!!! ***/
#ifdef PEX_RTOS_INIT
	PEX_RTOS_INIT();                   /* Initialization of the selected RTOS. Macro is defined by the RTOS component. */
#endif
	/*** End of Processor Expert internal initialization.                    ***/

	/* Write your code here */
	/* For example: for(;;) { } */


	CLOCK_DRV_Init(&clockMan1_InitConfig0);



	PINS_DRV_Init(NUM_OF_CONFIGURED_PINS, g_pin_mux_InitConfigArr);




	/* tasks should be created here!!!!!! */
	xTaskCreate( vLEDTask, ( const char * const ) "LedTask", configMINIMAL_STACK_SIZE, (void*)0, 4, NULL );

	/* Start the scheduler. */
	vTaskStartScheduler();



















	/*** Don't write any code pass this line, or it will be deleted during code generation. ***/
  /*** RTOS startup code. Macro PEX_RTOS_START is defined by the RTOS component. DON'T MODIFY THIS CODE!!! ***/
  #ifdef PEX_RTOS_START
    PEX_RTOS_START();                  /* Startup of the selected RTOS. Macro is defined by the RTOS component. */
  #endif
  /*** End of RTOS startup code.  ***/
  /*** Processor Expert end of main routine. DON'T MODIFY THIS CODE!!! ***/
  for(;;) {
    if(exit_code != 0) {
      break;
    }
  }
  return exit_code;
  /*** Processor Expert end of main routine. DON'T WRITE CODE BELOW!!! ***/
} /*** End of main routine. DO NOT MODIFY THIS TEXT!!! ***/

/* END main */
/*!
 ** @}
 */
/*
 ** ###################################################################
 **
 **     This file was created by Processor Expert 10.1 [05.21]
 **     for the NXP C55 series of microcontrollers.
 **
 ** ###################################################################
 */

externalFunctions.h

/*
 * externalFunctions.h
 *
 *  Created on: 2021年2月10日
 *      Author: ruina
 */

#ifndef EXTERNALFUNCTIONS_H_
#define EXTERNALFUNCTIONS_H_



#endif /* EXTERNALFUNCTIONS_H_ */

#include "Cpu.h"


void vLEDTask();

externalFunctions.c

/*
 * externalFunctions.c
 *
 *  Created on: 2021年2月10日
 *      Author: ruina
 */
#include "externalFunctions.h"



void vLEDTask()
{
	PINS_DRV_WritePin(PTA, 10, 0);	//led on
	for( ;; )
	{
		//		PINS_DRV_ClearPins(PTA, (0 << 0U));
		//		PINS_DRV_ClearPins(PTA, (1 << 10U));


		PINS_DRV_WritePin(PTA, 4, 0);	//led on
		PINS_DRV_WritePin(PTA, 0, 1);	//led off
		vTaskDelay( 500 );
		PINS_DRV_WritePin(PTA, 4, 1);	//led off
		PINS_DRV_WritePin(PTA, 0, 0);	//led on

		//		PINS_DRV_SetPins(PTA, (1 << 0U));
		//		PINS_DRV_SetPins(PTA, (0 << 10U));

		vTaskDelay( 500 );
	}
}


  1. 代码分析

如图所示

在这里插入图片描述
在这里插入图片描述

  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 3
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值