在线时间0 小时
UID3962955
注册时间2024-3-23
NXP金币39
该用户从未签到
新手上路
- 积分
- 16
- 最后登录
- 2024-3-24
|
手上有一块FRDM-S32K144的开发板,其他的例程GPIO这些配置怎么都没问题,包括LPTMR这些官方example都没问题,但是就是这个FTM定时中断怎么都进不去,各位朋友有没有遇到过,折腾了很多天了,是哪里没有配置正确吗
- /*
- * Copyright (c) 2015 - 2016 , Freescale Semiconductor, Inc.
- * Copyright 2016 - 2019 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.
- */
- /* Including needed modules to compile this module/procedure */
- #include "Cpu.h"
- #include "clockMan1.h"
- #include "pin_mux.h"
- #include "flexTimer_mc1.h"
- #if CPU_INIT_CONFIG
- #include "Init_Config.h"
- #endif
- volatile int exit_code = 0U;
- /* User includes (#include below this line is not maintained by Processor Expert) */
- #include <stdint.h>
- #include <stdbool.h>
- /* This example is setup to work by default with EVB. To use it with other boards
- please comment the following line
- */
- #define EVB
- #ifdef EVB
- #define LED_PIN 8U /* LED pin on PTD15 for the EVB Board */
- #define LED_GPIO PTE
- #else
- #define LED_PIN 0U /* LED pin PTC0 */
- #define LED_GPIO PTC
- #endif
- /* Flex Timer Instance interrupt service routine
- * - this will toggle LED 1 and clear the timer overflow flag of the FTM
- * instance
- */
- void ftmTimerISR(void)
- {
- PINS_DRV_WritePin(PTB,4,1);
- /* Static variable for storing the timer overflow count */
- static uint8_t s_overflowCount = 0U;
- /*
- * Since the FTM timer is configured to raise an IRQ every 100 ms,
- * the number of overflows for 1s is 10 time
- */
- if(s_overflowCount < 9U)
- {
- /* If the overflow count is below 9, increment it */
- s_overflowCount++;
- }
- else
- {
- /* If the overflow count is 9, toggle the LED and reset the variable */
- /* Toggle LED */
- PINS_DRV_TogglePins(LED_GPIO, 1 << LED_PIN);
- s_overflowCount = 0U;
- }
- /* Clear FTM Timer Overflow flag */
- FTM_DRV_ClearStatusFlags(INST_FLEXTIMER_MC1, (uint32_t)FTM_TIME_OVER_FLOW_FLAG);
- }
- /*!
- \brief The main function for the project.
- \details The startup initialization sequence is the following:
- * - __start (startup asm routine)
- * - __init_hardware()
- * - main()
- * - PE_low_level_init()
- * - Common_Init()
- * - Peripherals_Init()
- */
- int main(void)
- {
- /* Write your local variable definition here */
- ftm_state_t ftmStateStruct;
- /*** 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 */
- /* Initialize and configure clocks
- * - see clock manager component for details
- */
- CLOCK_SYS_Init(g_clockManConfigsArr, CLOCK_MANAGER_CONFIG_CNT,
- g_clockManCallbacksArr, CLOCK_MANAGER_CALLBACK_CNT);
- CLOCK_SYS_UpdateConfiguration(0U, CLOCK_MANAGER_POLICY_AGREEMENT);
- /* Initialize pins
- * - See PinSettings component for more info
- */
- PINS_DRV_Init(NUM_OF_CONFIGURED_PINS, g_pin_mux_InitConfigArr);
- /* Initialize GPIO
- * - set direction (out)
- * - set initial value
- */
- PINS_DRV_SetPinsDirection(LED_GPIO, (1 << LED_PIN));
- PINS_DRV_SetPins(LED_GPIO, (1 << LED_PIN));
- /* Initialize Flex Timer instance as simple timer */
- FTM_DRV_Init(INST_FLEXTIMER_MC1, &flexTimer_mc1_InitConfig, &ftmStateStruct);
- /* Install handler for the Timer overflow interrupt and enable it */
- INT_SYS_InstallHandler(FTM0_Ovf_Reload_IRQn, &ftmTimerISR, (isr_t*) 0U);
- INT_SYS_EnableIRQ(FTM0_Ovf_Reload_IRQn);
- /* Setup the counter to trigger an interrupt every 100 ms */
- FTM_DRV_InitCounter(INST_FLEXTIMER_MC1, &flexTimer_mc1_TimerConfig);
- /* Start the counter */
- FTM_DRV_CounterStart(INST_FLEXTIMER_MC1);
- /* Unless an IRQ has been raised, do nothing */
- while(1)
- {
- }
- /*** 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 Freescale S32K series of microcontrollers.
- **
- ** ###################################################################
- */
复制代码
|
-
|