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

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

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

2,053件の閲覧回数
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;

ラベル(1)
タグ(1)
0 件の賞賛
返信
3 返答(返信)

1,931件の閲覧回数
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 件の賞賛
返信

1,931件の閲覧回数
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 件の賞賛
返信

1,931件の閲覧回数
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 件の賞賛
返信