loading an instant value to ftm.CNT counter value while counting in quadrature decoder mode

cancel
Showing results for 
Search instead for 
Did you mean: 

loading an instant value to ftm.CNT counter value while counting in quadrature decoder mode

234 Views
amerzater
Contributor III

I am using FTM2 on MKV10z32 as quadrateure decoder . and some times while running I  re-synchronize the counter with a specific value and continue counting in the quadrature decoding mode from 0x0000 to 0xffff

I am using the next code to load the instant value(x) . but it seems that it dosnt work:

FTM2->SC=0x00;
FTM2->MOD=0xFFFF;
FTM2->CNTIN=x;
FTM2->CONTROLS[0].CnSC=0;
FTM2->CONTROLS[1].CnSC=0;
FTM2->QDCTRL|=0x01;
FTM2->MODE|=0x05;
FTM2->SC=0x48;
FTM2->CNTIN=0;

Labels (1)
Tags (1)
0 Kudos
3 Replies

112 Views
jingpan
NXP TechSupport
NXP TechSupport

Hi,

You code seems same as AN5142 quadrature encode example. Do you mean at first it can work correctly, but you can't write new value to FTM2->MOD or FTM2->CNTIN?

https://community.nxp.com/message/323855

QEI inputs, and index capture 

Regards,

Jing

0 Kudos

112 Views
amerzater
Contributor III

the quadrature encoder works just fine after the first init. but when I need to load a new value to FTm->CNT during running. I do the next to load the new value by means of CNTIN 

  1. stop ftm clock
  2. load new data  to CNTIN and CNT regs
  3.  run ftm clock
  4. reset CNTIN to allow counting from 0x0000 to FFFF

but it didnt work !!.

0 Kudos

112 Views
jingpan
NXP TechSupport
NXP TechSupport

Hi,

I made a demo to test how to update CNTIN and CNT. It use PTC1 and PTC2 to simulate quadrature input. You can see that any writing to CNT will make  it reload CNTIN value.

Regards,

Jing

0 Kudos