MCUXpressco - FTM0 for delay function doesn't work

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

MCUXpressco - FTM0 for delay function doesn't work

2,932 Views
tonytao
Contributor III

Hi,

I am doing a project with MCUXpressco IDE and MK22FN512VLH12 MCU. and the FTM0 for delay function doesn't work.

please see attached Clock setting, FTM0 setting and Code.

Did I missing something?

thanks for the help.

0 Kudos
9 Replies

2,790 Views
tonytao
Contributor III

So far, at least base on my knowledge, the SDK for MK22F family MCU doesn't support CPP well. I can use SDK examples to learn to make my C project, but I can't make my CPP project in a similar way.

0 Kudos

2,790 Views
Hui_Ma
NXP TechSupport
NXP TechSupport

Hi,

Please check if FTM0 counter start working. There missing FTM0 initialization code and start timer called:

 FTM_StartTimer(BOARD_FTM_BASEADDR, kFTM_SystemClock);

Wish it helps.


Have a great day,
Mike

-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!

- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------

0 Kudos

2,790 Views
tonytao
Contributor III

Hi Mike,

Please see attached pictures, there are cames from two project, one is FTM working and another one not.

All hardware condition are same. Clock seting are same.

Hope this information may help.

Kind regards,

Tony Tao

Engineering Technician

AXYZ Automation Inc.

(905) 634-4940 Ext. 262

0 Kudos

2,790 Views
Hui_Ma
NXP TechSupport
NXP TechSupport

Hi Tony,

Please check the FTM0_SC register value for working project vs. non-working project.

best regards,

Mike

-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!

- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------

0 Kudos

2,790 Views
tonytao
Contributor III

Hi Mike,

Please see attached pictures.

Kind regards,

Tony Tao

Engineering Technician

AXYZ Automation Inc.

(905) 634-4940 Ext. 262

0 Kudos

2,790 Views
Hui_Ma
NXP TechSupport
NXP TechSupport

Hi,

From FTM0 register, the counter starts working and TOF(timer overflow flag) is set. Then, the interrupt should be entered.

In general, I checked the SDK demo FTM0 interrupt service routine default named is FTM0_IRQHandler.

So, please check the project and make sure using below two interrupt definitions:

FTM0_IRQn  &  FTM0_IRQHandler

Otherwise, the FTM0 interrupt service routine will never entered.

Below is an example for your reference:

/* Interrupt number and interrupt handler for the FTM instance used */
#define BOARD_FTM_IRQ_NUM FTM0_IRQn
#define BOARD_FTM_HANDLER FTM0_IRQHandler


Have a great day,
Mike

-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!

- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------

0 Kudos

2,790 Views
tonytao
Contributor III

Hi Mike,

Appreciate your effort, that is the tough part.

Please see the attached pictures. All those pictures come from a non-working project.

FTM0 Registers.JPG: FTM0 is working.

Main.jpg: Interrupt handler is not working.

Peripherals Head file.jpg: it defined FTM0_IRQn & FTM0_IRQHANDLER already. But I used FTM0_IRQHandler directly.

Interrupt print.jpg: Add the printf in the interrupt handler, to make sure the code does not get in the handler at all.

#define added.jpg: even I added the define in the code, it still not working.

I imported the SDK example code, and it is working!

But any new project I created had a problem with FTM0. I do want to create a CPP project, but the example code is a C project……

Kind regards,

Tony Tao

Engineering Technician

AXYZ Automation Inc.

(905) 634-4940 Ext. 262

0 Kudos

2,790 Views
Hui_Ma
NXP TechSupport
NXP TechSupport

Hi,

For you could run SDK demo without any problem, there shows the hardware working.

Then it need to check the software code.

I think that could be registers setting difference cause the issue.

I abstracted the working projects FTM0 registers and core NVIC registers values for your reference:

pastedImage_1.png

pastedImage_2.png

Please check if your C++ project also has the similar values of those registers.

Wish it helps.


Have a great day,
Mike

-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!

- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------

0 Kudos

2,790 Views
tonytao
Contributor III

Hi Mike,

Thanks for your responding.

Unfurturnly, the FTM0 still not working. Detail please see attached screen captures.

Kind regards,

Tony Tao

Engineering Technician

AXYZ Automation Inc.

(905) 634-4940 Ext. 262

0 Kudos