ADC on FRDM problem.

cancel
Showing results for 
Search instead for 
Did you mean: 

ADC on FRDM problem.

Jump to solution
1,816 Views
filipsobczak
Contributor II

Hey. In my project I'm using 5 single ended ADC channels. I connected my force sensitive resistors to pins PTE20( ADC0_SE0 ), PTE21( ADC0_SE4a ), PTE22( ADC0_SE3 ), PTE 23( ADC0_SE7a ), PTE29(ADC0_SE4b). Then I created 5 static sample groups ( I'm using the ADC_LDD component ) each with one distinct channel assigned.

Three ADC channels work fine. When I want to measure the value on the sensor connected to PTE20 I use the following code:

                             Error = AD1_SelectSampleGroup(MyADCPtr, 0U);
Error = AD1_StartSingleMeasurement(MyADCPtr); // Start continuous measurement
while (!AD1_GetMeasurementCompleteStatus(MyADCPtr)) {}; // Wait for conversion completeness
Error = AD1_GetMeasuredValues(MyADCPtr, (LDD_TData *)MeasuredValue);  // Read measured values
FsrReadings[0] = MeasuredValue[0];
SendUint8_t_1(FsrReadings[0], &deviceData_1);

For each sensor I change the second argument in SelectSampleGroup method and the element number in FsrReadings according to the channel I want to measure. The rest stays the same.

If I touch the sensor connected to PTE20 everything works just fine. It's the same with PTE22( ADC0_SE3 ) and PTE29(ADC0_SE4b).

But when I want to get the measurment form the sensor connected to PTE21( ADC0_SE4a ) I get MeasuredValue[0] = 0 despite touching it. But if I touch the PTE20 sensor instead of PTE21 it measures the value for the PTE20 sensor. So if I measure them both at once (one after the other in the code) and press PTE20 i get FsrReadings[PTE20]=FsrReadings[PTE21]. If I touch PTE21 it looks as if I hadn't touched any sensors FsrReadings[PTE20]=FsrReadings[PTE21]=0. It's the same for the pair PTE22 / PTE23 ( PTE23 doesn't work ).

Do you know what may have caused this? Might it have anything to do with the 'a' letter at the end of ADC channel name ( ADC0_SE4a, ADC0_SE7a )?

There's one more thing I'd like to ask. If I take measurements from all 5 sensors and touch only one of them I get a '1' instead of a '0' for the measurement from the next channel.

If any of those problems might have been caused by wrong selection of conversion time, my settings are: A/D resolution - 8 bits, conversion time - 3.27us.

Tags (2)
0 Kudos
1 Solution
684 Views
Petr_H
NXP Employee
NXP Employee

Hello,

I was informed that there is a Processor Expert problem when an code is incorrectly generated so the pins are selected incorrectly (exchanged). The problem has been already fixed and the fix will be available in the final version of CW10.3, that should be available next week.

Unfortunately, there is additionally a limitation that the AD1_SelectSampleGroup method of the ADC_LDD component cannot handle the MUX switching between "a" and "b" pins (e.g. you are using ADC0_SE4a and ADC0_SE4b). 

At the moment, it needs to be resolved (as already suggested in previous post) by using only one type of pins (a or b  for all channels) or you would have to add your own code handling the pin and channel selection. We are planning to improve this in the next version.

best regards
Petr Hradsky
Processor Expert Support Team

View solution in original post

0 Kudos
4 Replies
685 Views
Petr_H
NXP Employee
NXP Employee

Hello,

I was informed that there is a Processor Expert problem when an code is incorrectly generated so the pins are selected incorrectly (exchanged). The problem has been already fixed and the fix will be available in the final version of CW10.3, that should be available next week.

Unfortunately, there is additionally a limitation that the AD1_SelectSampleGroup method of the ADC_LDD component cannot handle the MUX switching between "a" and "b" pins (e.g. you are using ADC0_SE4a and ADC0_SE4b). 

At the moment, it needs to be resolved (as already suggested in previous post) by using only one type of pins (a or b  for all channels) or you would have to add your own code handling the pin and channel selection. We are planning to improve this in the next version.

best regards
Petr Hradsky
Processor Expert Support Team

0 Kudos
684 Views
adriansc
Contributor IV

Hi,

Maybe this information will help you. An analog pin with b or a suffix are different, are not the same external pin, but both are the same ADC channel, you can see this in the next figure (Kinetis Microcontroller K60 RM Figure 3-32. ADCx_SEn channels a and b selection ):

2929_2929.png

As Earl Goodrich II said, the MUXSEL value is defined in ADCx_CFG2.

I recommend to use only one pin for each channel (a or b). Instead of changing MUXSEL value each time you read ADCx_SExa or ADCx_SExb.

Some pins are ADC default, if you are using one of them for another module you will need to change MUX value in PCR register.

Hope this helps.

684 Views
egoodii
Senior Contributor III

I don't know anything about the particular driver you are using (ADC_LDD), but certainly the 'a' vs. 'b' suffix on SE channels directly defines the required value of MUXSEL in ADCx_CFG2.  Don't ASK me why the ADC has two signal multiplexer controls...

0 Kudos
684 Views
filipsobczak
Contributor II

So I've been looking for some sort of connection between PTE20|PTE21 and PTE22|PTE23. I noticed that in those two pairs, the working sensor is connected to a pin that is the Tx pin of an UART module, while the other one is connected to Rx of the same module. But might that have any influence on the ADC channels? I'm not even using UART2 ( PTE22|PTE23 ), though I'm using UART0 (PTE20|PTE21). I realize that it's a wild guess, but who knows ;p

0 Kudos