Kinetis K10 FTM driver initialisation

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

Kinetis K10 FTM driver initialisation

845 Views
Dilebo
Contributor III

Hello all,

I'm writing an FTM driver for a K10.

I would like to know how to quickly update registers (MOD, CnV, CNTIN) from write buffers.

With my actual configuration, these registers are updated after CNT reaches 0xFFFF and returns to 0x0000. This is conform to the section 35.4.10 of the Ref. Man.

Is there a way to force the update instead of waiting that CNT reaches 0xFFFF ?

Here is the actual config :

    /* FTM_OUTINIT - Set the outputs default value for all channels */

    FTM_OUTINIT_REG(base) = 0U;

    /* FTM_MODE */

    FTM_MODE_REG(base) = FTM_MODE_WPDIS_MASK | FTM_MODE_INIT_MASK;   /* Disable write protection */

    /* FTM_SC */

    FTM_SC_REG(base) = FTM_SC_CLKS(1) |

                       FTM_INTERRUPT_OFF |

                       FTM_SC_PS(3);

    /* Configure the synchronization of FTM registers */

    FTM_SYNCONF_REG(base) = FTM_SYNCONF_SYNCMODE_MASK /* Enhanced mode */

                           | FTM_SYNCONF_SWWRBUF_MASK;  /* MOD, CNTIN, CnV updated on soft trig */

    /* Configure a software trigger to update FTM registers */

    FTM_SYNC_REG(base) = FTM_SYNC_SYNCHOM_MASK;

    /* FTM_CNTIN - Reset counter */

    FTM_CNTIN_REG(base) = 0U;

    FTM_CNT_REG(base)   = 0U;

    /* FTM_MOD - Modulo : set it to the max value*/

    FTM_MOD_REG(base) = FTM_MOD_MOD_MASK;

and for each channel

    /* FTM_POL - Set channel polarity */

    FTM_POL_REG(base) |= (uint32)(FTM_CH_POL_HIGH << channel);

    /* FTM_CnSC */

    FTM_CnSC_REG(base, channel) = FTM_CH_IT_OFF;

    FTM_CnSC_REG(base, channel) = ( FTM_CnSC_MSB_MASK |

                                    FTM_CnSC_ELSB_MASK );

    /* FTM_CV - Channel value */

    FTM_CnV_REG(base, channel) = FTM_CnV_VAL(usCV);

eventually

/* Software trig to synchronize all of the FTM registers */

    FTM_SYNC_REG(DRV_FTM_BaseAddress[index]) |= FTM_SYNC_SWSYNC_MASK;

I though this last line would do the job but it doesn't.

Thanks for your help.

Labels (1)
Tags (4)
0 Kudos
1 Reply

299 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi Dilebo,

    I think, maybe this application notes will help you about your question.

    Then link is :

    http://cache.freescale.com/files/microcontrollers/doc/app_note/AN4560.pdf?fromsite=zh-Hans

    Wish it helps you!

Best regards!

Jing