9 years, 2 months ago.

FRDM K64FZ Analog In - PWM issue

Hi, I am trying to use pin A5 of FRDM-K64FZ as an analog input pin. I am getting proper response from all pins from A0 to A3 but it is not giving correct results on A4 and A5. What I have concluded is that these are PWM pins so there must be some issue with that. Can anyone help me getting these pins work as Analog Input pins. I used AnalogIn pin1(A5) declaration for this pin. Thanks in Advance.

2 Answers

9 years, 1 month ago.

Fahd Ansary wrote:

Thank you very much for the reply. I got it working now. The issue was not swap but ADC pairs. A4 and A5 are 'b' part of ADC pairs and by default 'a' parts are selected. ADC0_CFG2=ADC0_CFG2||0x10; sets the MUXSEL bit in config2 register which selects all 'b' parts of ADCs. A0 to A3 are single ADCs and not pairs so this has no effect on them.

Accepted Answer
9 years, 2 months ago.

I think A4 and A5 are swapped, seems like a bug. In stead of A4 and A5, try using PTC11 (for A4), and PTC10(for A5). If you look at the "..\mbed\TARGET_K64F\TARGET_Freescale\TARGET_KPSDK_MCUS\TARGET_MCU_K64F\TARGET_FRDM\PinNames.h" file, you will see they declared A4 = PTC10, and A5 = PTC11. This seems to be swapped.

I think this was fixed in the last mbed revision. I checked the latest K64F schematic, available on the net, also the platform page has it defined as that. I used to have older,where they were swapped.

posted by Martin Kojtal 06 Mar 2015

Hi Martin, OK, I just checked on GitHub, and the PinNames.h file was fixed 3 days ago, I guess it must be included with latest v95 that was released 2 days ago. I missed that new release.

posted by modtronix H 06 Mar 2015

Thank you very much for the reply. I got it working now. The issue was not swap but ADC pairs. A4 and A5 are 'b' part of ADC pairs and by default 'a' parts are selected. ADC0_CFG2=ADC0_CFG2||0x10; sets the MUXSEL bit in config2 register which selects all 'b' parts of ADCs. A0 to A3 are single ADCs and not pairs so this has no effect on them.

posted by Fahd Ansary 09 Mar 2015