Enable channel B for ADC module 1 in IMXRT1176

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

Enable channel B for ADC module 1 in IMXRT1176

648 Views
Jeevan
Contributor IV

Hi team,

We are planning to use 5 ADC channels.

So we selected ADC module 1 and in that 5 channnels we are using :: Channel 1A, 2A, 1B, 2B and 3B.... 

In the SDK example of imxrt1170 by the name "adc software trigger", i am able to change the ADC channel to 1, 2 and its working only for channel 1A and 2A.

How to make it work for 1B, 2B and 3B channel [what is the software change to be done apart from selecting the particular pin in the pinconfig utility of mcuxpresso ide] ?

0 Kudos
Reply
3 Replies

615 Views
Gavin_Jia
NXP TechSupport
NXP TechSupport

Hi @Jeevan ,

Thanks for your interest in NXP MIMXRT series.

Please consult this structure `lpadc_conv_command_config_t`:

typedef struct
{
#if defined(FSL_FEATURE_LPADC_HAS_CMDL_CSCALE) && FSL_FEATURE_LPADC_HAS_CMDL_CSCALE
    lpadc_sample_scale_mode_t sampleScaleMode;     /*!< Sample scale mode. */
#endif                                             /* FSL_FEATURE_LPADC_HAS_CMDL_CSCALE */
#if defined(FSL_FEATURE_LPADC_HAS_CMDL_ALTB_CSCALE) && FSL_FEATURE_LPADC_HAS_CMDL_ALTB_CSCALE
    lpadc_sample_scale_mode_t channelBScaleMode;   /*!< Alternate channe B Scale mode. */
#endif                                             /* FSL_FEATURE_LPADC_HAS_CMDL_ALTB_CSCALE */
    lpadc_sample_channel_mode_t sampleChannelMode; /*!< Channel sample mode. */
    uint32_t channelNumber;                        /*!< Channel number, select the channel or channel pair. */
#if defined(FSL_FEATURE_LPADC_HAS_CMDL_ALTB_ADCH) && FSL_FEATURE_LPADC_HAS_CMDL_ALTB_ADCH
    uint32_t channelBNumber;                       /*!< Alternate Channel B number, select the channel. */
#endif
    uint32_t chainedNextCommandNumber; /*!< Selects the next command to be executed after this command completes.
                                            1-15 is available, 0 is to terminate the chain after this command. */
    bool enableAutoChannelIncrement;   /*!< Loop with increment: when disabled, the "loopCount" field selects the number
                                            of times the selected channel is converted consecutively; when enabled, the
                                            "loopCount" field defines how many consecutive channels are converted as part
                                            of the command execution. */
    uint32_t loopCount; /*!< Selects how many times this command executes before finish and transition to the next
                             command or Idle state. Command executes LOOP+1 times.  0-15 is available. */
    lpadc_hardware_average_mode_t hardwareAverageMode; /*!< Hardware average selection. */
    lpadc_sample_time_mode_t sampleTimeMode;           /*!< Sample time selection. */

    lpadc_hardware_compare_mode_t hardwareCompareMode; /*!< Hardware compare selection. */
    uint32_t hardwareCompareValueHigh; /*!< Compare Value High. The available value range is in 16-bit. */
    uint32_t hardwareCompareValueLow;  /*!< Compare Value Low. The available value range is in 16-bit. */
#if defined(FSL_FEATURE_LPADC_HAS_CMDL_MODE) && FSL_FEATURE_LPADC_HAS_CMDL_MODE
    lpadc_conversion_resolution_mode_t conversionResolutionMode; /*!< Conversion resolution mode. */
#endif                                                           /* FSL_FEATURE_LPADC_HAS_CMDL_MODE */
#if defined(FSL_FEATURE_LPADC_HAS_CMDH_WAIT_TRIG) && FSL_FEATURE_LPADC_HAS_CMDH_WAIT_TRIG
    bool enableWaitTrigger; /*!< Wait for trigger assertion before execution: when disabled, this command will be
                                 automatically executed; when enabled, the active trigger must be asserted again before
                                 executing this command. */
#endif                      /* FSL_FEATURE_LPADC_HAS_CMDH_WAIT_TRIG */
#if defined(FSL_FEATURE_LPADC_HAS_CMDL_ALTBEN) && FSL_FEATURE_LPADC_HAS_CMDL_ALTBEN
    bool enableChannelB;    /*! Enable alternate Channel B */
#endif                      /* FSL_FEATURE_LPADC_HAS_CMDL_ALTBEN */
} lpadc_conv_command_config_t;

--> lpadc_sample_channel_mode_t sampleChannelMode;

It needs to be properly assigned in the variables you use to indicate whether to use channel A or channel B or both of them.

mLpadcCommandConfigStruct.sampleChannelMode = kLPADC_SampleChannelSingleEndSideB;
mLpadcCommandConfigStruct.channelNumber = DEMO_LPADC_USER_CHANNEL;

Gavin_Jia_0-1708664129368.png

 

 

Best regards,
Gavin

0 Kudos
Reply

579 Views
Jeevan
Contributor IV

Hi @Gavin_Jia ,

Thank you for your valuable information regarding the usage of channel B.

But we wanted to configure both channel A and channel B as single ended modes operating independently. Can you please suggest what is code modification required to make it operate independently.

As shown in the below adc driver file always its entering the IF condition block. but we wanted to use the ELIF condition to select  "kLPADC_SampleChannelDualSingleEndBothSide" to make A and B channel operate independently.

Jeevan_0-1708948399778.png

 

0 Kudos
Reply

570 Views
Gavin_Jia
NXP TechSupport
NXP TechSupport

Hi @Jeevan ,

The RT1170 ADC does not support dual single-ended modes, only single-ended and differential modes.

The driver used is publicly reusable, and the RT1170 skips this dual single-ended mode in the code with a conditional compilation instruction.
Specifically, that is:

/* @brief Has conversion type select (bitfield CMDLn[CTYPE]). */
#define FSL_FEATURE_LPADC_HAS_CMDL_CTYPE (0)

As you can see in the RM, the CMDLn register does not have the bit CTYPE:

Gavin_Jia_0-1708997964061.png

As an example, use another ADC that supports three sampling modes, such as (MCXN947), which supports single-ended, differential, and dual single-ended modes:

Gavin_Jia_1-1708998044312.pngGavin_Jia_2-1708998064436.png

I hope this helps.

 

Best regards,

Gavin

0 Kudos
Reply