AnsweredAssumed Answered

Basic FTM settings

Question asked by Tomáš Pilný on Apr 26, 2015

Hello everybody,


I am new to this forum and I've just started with kinetis, so please try to keep that in mind.

I am using MK60N512VMD100 on custom board, with CW v10.6.


First I'll try to explain my aim - I am trying to write simple application for Ultrasonic Ranging Module HC - SR04.

The module needs to be triggered by 10 micro second pulse, then it outputs pulse with range in proportion (the time it took for sound wave to travel from module, to measured object and back).

I want to have, lets say, 7 modules, fairly close together, but I want to detect object (hand) only for one of the modules.


So what I need is to set FTM to generate one pulse on one pin, and then measure the echo signal on another pin. This all is to be repeated for another module, on another pin. I think that the trigger signal could be the same for all modules, but I would be measuring only one of them at a time (to avoid capturing echo from different module.)


I've been trying to learn the correct setting from Reference Manual and tons of post all around the internet - without luck.

Now for the code. For start I'm trying to do the 10us pulse. The idea is to use edge aligned PWM, high-true pulses, clear on match. When the counter (CNT) reaches the modulo value (MOD) I catch the interrupt and disable the FTM. I'm not realy sure if it is the best way, or even if it leads to my destination


The biggest problem now is that the program crashes at line FTM0_SC |= FTM_SC_CLKS(0x01) | FTM_SC_TOIE_MASK;

When I run it full speed without breakpoints or I step through it just stops executing. When I hit the Suspend button I get "Target request failerd: ARM GDI Protocol Adapter : Stop failed. Non Fatal Error."


Do you have any ideas where the problem might be?


Thanks in advance


Original Attachment has been moved to: