How to set Quadrature Decoder mode on VF50?

How to set Quadrature Decoder mode on VF50 for pwm to read rotary encoder?

VF50, Iris V1.1 carrier board, wince6

In your initial question, you stated the Viola V1.1, now you mention the Iris V1.1. Could you please clarify?

I am doing testing on iris and will use Viola for final product. So If it works for any of the two carrier board, I can do it for other.

Dear @Mania

We don’t have an example how to use the Quardrature Decoder, but I can give you some hints how to implement this feature:

The signals PHA and PHB are available on the SODIMM connector. There’s a second GPIO connected to each of these signals, which must be tristated.

Signal | SODIMM Pin | VFxx GPIO      | Additional GPIO (Tristate!) 
-------|------------|----------------|-----------------------------.
PHA    | 28         | PTB8 (AltFn 3) | -
PHB    | 67         | PTB9 (AltFn 3) | PTC6

To use the Quadrature Decoder, you need to program the Flexible Timer Module (FTM). Please refer to the Vybrid Reference Manual Section 13.1.4.25 for details how to use it. After setting up the decoder, the FTM provides basically a counter which counts up and down automatically, according to the signals PHA and PHB.

The Toradex CE Libraries support you to write the necessary code:

  • Use the GpioLib to configure the GPIOs PTB8, PTB9 and PTC6.
  • Use the MapMemoryLib to get direct access to the FTM registers.

Best Regards, Andy

How to use the MapMemoryLib to get direct access to the FTM registers?

Dear @Mania
Please let us know your environment. Which OS are you using?
Regards, Andy

Thanks for your quick information @andy.tx

Dear @Mania

With the MapMemLib you can make the physical address space accessible from your application. The following code snippet shows how to do it.

{
    HANDLE hMap = Map_Init();
    DWORD *reg = (DWORD *)Map_MapMemory(physicalAddress, blocksize);
        // reg is now a pointer to the registers at <physicalAddress>
    Map_UnMapMemory(reg);
    Map_Deinit(hMap);
}

Regards, Andy

Dear @andy
Can you please tell me how I get the physical address? I connected wires of encoder to the pin No. 28 & pin No. 67. I set the configuration of PTB8, PTB9 and PTC6 to AltFn 3. Now how I will get the output of encoder?

Dear @Mania
You can find the physical address mapping and other details about accessing the encoder in the VF50 reference manual. This should be available on the nxp web site.
Regards, Andy

Dear @andy.tx
From the reference manual I got the IOMuxC_PTB8 40048078, IOMuxC_PTB9 4004807C and IOMuxC_PTC6 400480CC. Is this the Physical address I have to use for memory mapping?
I also want to know that after mapping the address, what should I need to do to get the value of rotary encoder counting.

Dear @Mania
We are happy to support our customers to solve detail problems where our special knowledge is required.
However, there is a point where we expect people to be able to continue on their own - it is beyond our possibilities to educate all our customers in general topics such as programming languages or reading a reference manual.
I could answer your last questions, but I know this would just lead to even more questions. I recommend you look for an engineering company who could help you finishing your task - it might be not the last time that you need this kind of support during your project.
You can go for a local company of your choice - or go to our partners website. There are a number of companies listed who offer general engineering services.
Best Regards, Andy