HOW TO CHANGE ADC CLOCK IN MQX?

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

HOW TO CHANGE ADC CLOCK IN MQX?

Jump to solution
663 Views
oliviachristyva
Contributor III

Hi guys.

I am doing an ADC code in MQX for FRDMK64. I used the LWADC example and made some changes an the code is working. But i want the ADC to run in full speed. I tried to change the clock by using

_lwadc_set_attribute(&lwadc_inputs[i],LWADC_FREQUENCY,12000000);

but after this command when i am printing this clock to see whether it changed. it shows 8Mhz clock. 

I tried to change the vref using this function then there is no change but whe i changed it in the BSP it is working.

#define BSP_ADC_VREF_DEFAULT            (3300)

But i dont know where to change the ADC clock in BSP.

Please help

Regards,

Olivia

0 Kudos
1 Solution
497 Views
danielchen
NXP TechSupport
NXP TechSupport

Hi Olivia:

In current LW ADC driver , LWADC_FREQUENCY value should be set  in the API _lwadc_init . this value can't be changed with _lwadc_set_attribute.

Please check this API, there is a table made from the datasheet

  
    const static uint32_t adc_max_frq_table[] = {
        2500000,  /* 2.5 MHz  for low power,    normal speed, 16b resolution */
        5000000,  /* 5.0 MHz  for low power,    normal speed, lower resolution */
        5000000,  /* 5.0 MHz  for low power,    high speed,   16b resolution */
        8000000,  /* 8.0 MHz  for low power,    high speed,   lower resolution */
        8000000,  /* 8.0 MHz  for normal power, normal speed, 16b resolution */
        12000000, /* 12.0 MHz for normal power, normal speed, lower resolution */
        12000000, /* 12.0 MHz for normal power, high speed,   16b resolution */
        18000000, /* 18.0 MHz for normal power, high speed,   lower resolution */
    };

If you want to use 12M, please change line 127

    if (init_ptr->POWER == LWADC_LPC_NORMAL)
        adc_max_frq_index |= 0x04;

to

        adc_max_frq_index |= 0x05;

I hope it helps


Have a great day,
Daniel

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

View solution in original post

0 Kudos
1 Reply
498 Views
danielchen
NXP TechSupport
NXP TechSupport

Hi Olivia:

In current LW ADC driver , LWADC_FREQUENCY value should be set  in the API _lwadc_init . this value can't be changed with _lwadc_set_attribute.

Please check this API, there is a table made from the datasheet

  
    const static uint32_t adc_max_frq_table[] = {
        2500000,  /* 2.5 MHz  for low power,    normal speed, 16b resolution */
        5000000,  /* 5.0 MHz  for low power,    normal speed, lower resolution */
        5000000,  /* 5.0 MHz  for low power,    high speed,   16b resolution */
        8000000,  /* 8.0 MHz  for low power,    high speed,   lower resolution */
        8000000,  /* 8.0 MHz  for normal power, normal speed, 16b resolution */
        12000000, /* 12.0 MHz for normal power, normal speed, lower resolution */
        12000000, /* 12.0 MHz for normal power, high speed,   16b resolution */
        18000000, /* 18.0 MHz for normal power, high speed,   lower resolution */
    };

If you want to use 12M, please change line 127

    if (init_ptr->POWER == LWADC_LPC_NORMAL)
        adc_max_frq_index |= 0x04;

to

        adc_max_frq_index |= 0x05;

I hope it helps


Have a great day,
Daniel

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos