FRDM-MCXW71: how to read light sensor with Zephyr OS?

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

FRDM-MCXW71: how to read light sensor with Zephyr OS?

634 Views
gja
Contributor II

Hello,

I'm using the NXP FRDM-MCXW71 board with Zephyr OS.
The goal is to test the ADC functionality.

For this the samples\drivers\adc\adc_dt example is reworked by adapting the overlay file in the boards folder. The ADC pin is changed from CH2A to CH6B in the overlay file of the adc_dt example.

A clean build is made and flashed. However when reading the resulting measurement over UART this does not seem to reflect the reading of the light sensor.
An alternative test was done with ADC input CH5B that is connected to a digital switch. UART reading also don't reflect the switch position.

Any suggestions what changes are missing to fix the ADC readings?
Thanks.

Tags (3)
0 Kudos
Reply
4 Replies

614 Views
Ricardo_Zamora
NXP TechSupport
NXP TechSupport

Hello,

 

Hope you are doing well. Could you please help us clarify what repository and version are you using?

Are you working with MCUXpresso for VSCode?

Have you tested the example as is? Is it working on your side?

 

Regards,

Ricardo

0 Kudos
Reply

567 Views
gja
Contributor II

The release is Release Zephyr 4.3.0 · zephyrproject-rtos/zephyr · GitHub

I'm not working with MCUXpresso. 
I had the least install issues with a Virtual Machine running Ubuntu and the standard Zephyr OS 4.3 install.

The standard sample is running, but is using ADC on pin A2.
On the schematic I find no mentioning of input A2.
The measurement results seems to indicate a floating pin.

0 Kudos
Reply

543 Views
gja
Contributor II

There is another example application under samples/sensor/light/polling

This example has an overlay for frdm_mcxw71 in the boards folder.
However the AD input here is specified as CH2B, while the schematic calls for ADC0_B6.

Output value on the serial console also seems to be fixed. No change when changing light.

 

 

0 Kudos
Reply

510 Views
gja
Contributor II

I tried the /samples/sensor/light/polling example on a different FRDM-MCXW71 board.

Board number 2 does show changes in the values printed on the UART console when covering the sensor.

The longer the test is running, the more change in value.

Testing board number 1 again: after waiting for a longer period this sensor also shows changes in values.

Summary: on board number 1 it takes about 20 seconds before the sensor shows some minor change in measurement. After a minute or so the values show realistic level changes.

I still don't understand the channel numbering: schematic shows ADC0_B6, code shows "Channel@2, MCUX_LPADC_CH2B" ?

 

0 Kudos
Reply
%3CLINGO-SUB%20id%3D%22lingo-sub-2336703%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3EFRDM-MCXW71%3A%20how%20to%20read%20light%20sensor%20with%20Zephyr%20OS%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2336703%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EHello%2C%3C%2FP%3E%3CP%3EI'm%20using%20the%20NXP%20FRDM-MCXW71%20board%20with%20Zephyr%20OS.%3CBR%20%2F%3EThe%20goal%20is%20to%20test%20the%20ADC%20functionality.%3C%2FP%3E%3CP%3EFor%20this%20the%20samples%5Cdrivers%5Cadc%5Cadc_dt%20example%20is%20reworked%20by%20adapting%20the%20overlay%20file%20in%20the%20boards%20folder.%20The%20ADC%20pin%20is%20changed%20from%20CH2A%20to%20CH6B%20in%20the%20overlay%20file%20of%20the%20adc_dt%20example.%3C%2FP%3E%3CP%3EA%20clean%20build%20is%20made%20and%20flashed.%20However%20when%20reading%20the%20resulting%20measurement%20over%20UART%20this%20does%20not%20seem%20to%20reflect%20the%20reading%20of%20the%20light%20sensor.%3CBR%20%2F%3EAn%20alternative%20test%20was%20done%20with%20ADC%20input%20CH5B%20that%20is%20connected%20to%20a%20digital%20switch.%20UART%20reading%20also%20don't%20reflect%20the%20switch%20position.%3C%2FP%3E%3CP%3EAny%20suggestions%20what%20changes%20are%20missing%20to%20fix%20the%20ADC%20readings%3F%3CBR%20%2F%3EThanks.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2336824%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%20translate%3D%22no%22%3ERe%3A%20FRDM-MCXW71%3A%20how%20to%20read%20light%20sensor%20with%20Zephyr%20OS%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2336824%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EHello%2C%3C%2FP%3E%0A%3CBR%20%2F%3E%0A%3CP%3EHope%20you%20are%20doing%20well.%20Could%20you%20please%20help%20us%20clarify%20what%20repository%20and%20version%20are%20you%20using%3F%3C%2FP%3E%0A%3CP%3EAre%20you%20working%20with%20MCUXpresso%20for%20VSCode%3F%3C%2FP%3E%0A%3CP%3EHave%20you%20tested%20the%20example%20as%20is%3F%20Is%20it%20working%20on%20your%20side%3F%3C%2FP%3E%0A%3CBR%20%2F%3E%0A%3CP%3ERegards%2C%3C%2FP%3E%0A%3CP%3ERicardo%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2337362%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%20translate%3D%22no%22%3ERe%3A%20FRDM-MCXW71%3A%20how%20to%20read%20light%20sensor%20with%20Zephyr%20OS%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2337362%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EThe%20release%20is%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2Fzephyrproject-rtos%2Fzephyr%2Freleases%2Ftag%2Fv4.3.0%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noreferrer%22%3ERelease%20Zephyr%204.3.0%20%C2%B7%20zephyrproject-rtos%2Fzephyr%20%C2%B7%20GitHub%3C%2FA%3E%3C%2FP%3E%3CP%3EI'm%20not%20working%20with%20MCUXpresso.%26nbsp%3B%3CBR%20%2F%3EI%20had%20the%20least%20install%20issues%20with%20a%20Virtual%20Machine%20running%20Ubuntu%20and%20the%20standard%20Zephyr%20OS%204.3%20install.%3C%2FP%3E%3CP%3EThe%20standard%20sample%20is%20running%2C%20but%20is%20using%20ADC%20on%20pin%20A2.%3CBR%20%2F%3EOn%20the%20schematic%20I%20find%20no%20mentioning%20of%20input%20A2.%3CBR%20%2F%3EThe%20measurement%20results%20seems%20to%20indicate%20a%20floating%20pin.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2337694%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%20translate%3D%22no%22%3ERe%3A%20FRDM-MCXW71%3A%20how%20to%20read%20light%20sensor%20with%20Zephyr%20OS%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2337694%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EThere%20is%20another%20example%20application%20under%20samples%2Fsensor%2Flight%2Fpolling%3C%2FP%3E%3CP%3EThis%20example%20has%20an%20overlay%20for%20frdm_mcxw71%20in%20the%20boards%20folder.%3CBR%20%2F%3EHowever%20the%20AD%20input%20here%20is%20specified%20as%20CH2B%2C%20while%20the%20schematic%20calls%20for%20ADC0_B6.%3C%2FP%3E%3CP%3EOutput%20value%20on%20the%20serial%20console%20also%20seems%20to%20be%20fixed.%20No%20change%20when%20changing%20light.%3C%2FP%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2338275%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%20translate%3D%22no%22%3ERe%3A%20FRDM-MCXW71%3A%20how%20to%20read%20light%20sensor%20with%20Zephyr%20OS%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2338275%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EI%20tried%20the%20%2Fsamples%2Fsensor%2Flight%2Fpolling%20example%20on%20a%20different%20FRDM-MCXW71%20board.%3C%2FP%3E%3CP%3EBoard%20number%202%20does%20show%20changes%20in%20the%20values%20printed%20on%20the%20UART%20console%20when%20covering%20the%20sensor.%3C%2FP%3E%3CP%3EThe%20longer%20the%20test%20is%20running%2C%20the%20more%20change%20in%20value.%3CBR%20%2F%3E%3CBR%20%2F%3ETesting%20board%20number%201%20again%3A%20after%20waiting%20for%20a%20longer%20period%20this%20sensor%20also%20shows%20changes%20in%20values.%3C%2FP%3E%3CP%3ESummary%3A%20on%20board%20number%201%20it%20takes%20about%2020%20seconds%20before%20the%20sensor%20shows%20some%20minor%20change%20in%20measurement.%20After%20a%20minute%20or%20so%20the%20values%20show%20realistic%20level%20changes.%3C%2FP%3E%3CP%3EI%20still%20don't%20understand%20the%20channel%20numbering%3A%20schematic%20shows%20ADC0_B6%2C%20code%20shows%20%22Channel%402%2C%20MCUX_LPADC_CH2B%22%20%3F%3C%2FP%3E%3CBR%20%2F%3E%3C%2FLINGO-BODY%3E