查看: 141|回复: 0

[S32] FRDM-S32K144的FTM定时中断怎么都进不去

[复制链接]

该用户从未签到

1

主题

1

帖子

0

新手上路

Rank: 1

积分
16
最后登录
2024-3-24
发表于 2024-3-23 23:03:19 | 显示全部楼层 |阅读模式
手上有一块FRDM-S32K144的开发板,其他的例程GPIO这些配置怎么都没问题,包括LPTMR这些官方example都没问题,但是就是这个FTM定时中断怎么都进不去,各位朋友有没有遇到过,折腾了很多天了,是哪里没有配置正确吗



  1. /*
  2. * Copyright (c) 2015 - 2016 , Freescale Semiconductor, Inc.
  3. * Copyright 2016 - 2019 NXP
  4. * All rights reserved.
  5. *
  6. * THIS SOFTWARE IS PROVIDED BY NXP "AS IS" AND ANY EXPRESSED OR
  7. * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  8. * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  9. * IN NO EVENT SHALL NXP OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
  10. * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  11. * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
  12. * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  13. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
  14. * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
  15. * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
  16. * THE POSSIBILITY OF SUCH DAMAGE.
  17. */


  18. /* Including needed modules to compile this module/procedure */
  19. #include "Cpu.h"
  20. #include "clockMan1.h"
  21. #include "pin_mux.h"
  22. #include "flexTimer_mc1.h"
  23. #if CPU_INIT_CONFIG
  24.   #include "Init_Config.h"
  25. #endif

  26. volatile int exit_code = 0U;
  27. /* User includes (#include below this line is not maintained by Processor Expert) */

  28. #include <stdint.h>
  29. #include <stdbool.h>

  30. /* This example is setup to work by default with EVB. To use it with other boards
  31.    please comment the following line
  32. */

  33. #define EVB

  34. #ifdef EVB
  35.     #define LED_PIN     8U         /* LED pin on PTD15 for the EVB Board */
  36.     #define LED_GPIO    PTE
  37. #else
  38.     #define LED_PIN     0U          /* LED pin PTC0 */
  39.     #define LED_GPIO    PTC
  40. #endif

  41. /* Flex Timer Instance interrupt service routine
  42. *  - this will toggle LED 1 and clear the timer overflow flag of the FTM
  43. *  instance
  44. */
  45. void ftmTimerISR(void)
  46. {
  47.         PINS_DRV_WritePin(PTB,4,1);
  48.     /* Static variable for storing the timer overflow count */
  49.     static uint8_t s_overflowCount = 0U;
  50.     /*
  51.      * Since the FTM timer is configured to raise an IRQ every 100 ms,
  52.      * the number of overflows for 1s is 10 time
  53.      */
  54.     if(s_overflowCount < 9U)
  55.     {
  56.         /* If the overflow count is below 9, increment it */
  57.         s_overflowCount++;
  58.     }
  59.     else
  60.     {
  61.         /* If the overflow count is 9, toggle the LED and reset the variable */
  62.         /* Toggle LED */
  63.         PINS_DRV_TogglePins(LED_GPIO, 1 << LED_PIN);
  64.         s_overflowCount = 0U;
  65.     }
  66.     /* Clear FTM Timer Overflow flag */
  67.     FTM_DRV_ClearStatusFlags(INST_FLEXTIMER_MC1, (uint32_t)FTM_TIME_OVER_FLOW_FLAG);
  68. }

  69. /*!
  70.   \brief The main function for the project.
  71.   \details The startup initialization sequence is the following:
  72. * - __start (startup asm routine)
  73. * - __init_hardware()
  74. * - main()
  75. *   - PE_low_level_init()
  76. *     - Common_Init()
  77. *     - Peripherals_Init()
  78. */
  79. int main(void)
  80. {
  81.   /* Write your local variable definition here */
  82.     ftm_state_t ftmStateStruct;
  83.   /*** Processor Expert internal initialization. DON'T REMOVE THIS CODE!!! ***/
  84.   #ifdef PEX_RTOS_INIT
  85.     PEX_RTOS_INIT();                 /* Initialization of the selected RTOS. Macro is defined by the RTOS component. */
  86.   #endif
  87.   /*** End of Processor Expert internal initialization.                    ***/

  88.   /* Write your code here */

  89.     /* Initialize and configure clocks
  90.      *  -   see clock manager component for details
  91.      */
  92.     CLOCK_SYS_Init(g_clockManConfigsArr, CLOCK_MANAGER_CONFIG_CNT,
  93.                    g_clockManCallbacksArr, CLOCK_MANAGER_CALLBACK_CNT);
  94.     CLOCK_SYS_UpdateConfiguration(0U, CLOCK_MANAGER_POLICY_AGREEMENT);

  95.     /* Initialize pins
  96.      *  -   See PinSettings component for more info
  97.      */
  98.     PINS_DRV_Init(NUM_OF_CONFIGURED_PINS, g_pin_mux_InitConfigArr);

  99.     /* Initialize GPIO
  100.      *  - set direction (out)
  101.      *  - set initial value
  102.      */
  103.     PINS_DRV_SetPinsDirection(LED_GPIO, (1 << LED_PIN));
  104.     PINS_DRV_SetPins(LED_GPIO, (1 << LED_PIN));

  105.     /* Initialize Flex Timer instance as simple timer */
  106.     FTM_DRV_Init(INST_FLEXTIMER_MC1, &flexTimer_mc1_InitConfig, &ftmStateStruct);

  107.     /* Install handler for the Timer overflow interrupt and enable it */
  108.     INT_SYS_InstallHandler(FTM0_Ovf_Reload_IRQn, &ftmTimerISR, (isr_t*) 0U);
  109.     INT_SYS_EnableIRQ(FTM0_Ovf_Reload_IRQn);

  110.     /* Setup the counter to trigger an interrupt every 100 ms */
  111.     FTM_DRV_InitCounter(INST_FLEXTIMER_MC1, &flexTimer_mc1_TimerConfig);
  112.     /* Start the counter */
  113.     FTM_DRV_CounterStart(INST_FLEXTIMER_MC1);

  114.     /* Unless an IRQ has been raised, do nothing */
  115.     while(1)
  116.     {

  117.     }

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

  133. /* END main */
  134. /*!
  135. ** @}
  136. */
  137. /*
  138. ** ###################################################################
  139. **
  140. **     This file was created by Processor Expert 10.1 [05.21]
  141. **     for the Freescale S32K series of microcontrollers.
  142. **
  143. ** ###################################################################
  144. */
复制代码



我知道答案 目前已有0人回答
微信图片_20240323230241.jpg
回复

使用道具 举报

您需要登录后才可以回帖 注册/登录

本版积分规则

关闭

站长推荐上一条 /4 下一条

Archiver|手机版|小黑屋|恩智浦技术社区

GMT+8, 2024-5-7 05:38 , Processed in 0.122645 second(s), 23 queries , MemCache On.

Powered by Discuz! X3.4

Copyright © 2001-2024, Tencent Cloud.

快速回复 返回顶部 返回列表