LWADC on ADC1SE9 possible?

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

LWADC on ADC1SE9 possible?

Jump to solution
2,211 Views
abacus
Contributor II

Hi,

I'm trying to use LWADC driver for ADC1SE9 channel for the VF6XX with MQX 4.1.1 for Linux. I have the following initialization:

if (!_lwadc_init(&lwadc1_init))

{

  printf("Failed to initialize ADC\n");

}

if (!_lwadc_init_input(&ntc_input, ADC_INPUT_ADC1_AN9))

{

  printf("Failed to initialize ADC input\n");

}

But it's failing in _lwadc_init_input function.

Debugging the code, I could find that the _bsp_adc_channel_io_init function uses an array of available ADC channels:

static const uint16_t adc_pin_map[ADC_NUM_DEVICES][ADC_HW_CHANNELS] = {

   {

      LWADC0_AN0,

      LWADC0_AN1,

      LWADC0_AN2,

      LWADC0_AN3,

      LWADC0_AN4,

      LWADC0_AN5,

      LWADC0_AN6,

      LWADC0_AN7,

      LWADC_SIG_NC,

      LWADC_SIG_NC,

      LWADC_SIG_NC,

      LWADC_SIG_NC,

      LWADC_SIG_NC,

      LWADC_SIG_NC,

      LWADC_SIG_NC,

      LWADC_SIG_NC,

   },

      {

      LWADC1_AN0,

      LWADC1_AN1,

      LWADC1_AN2,

      LWADC1_AN3,

      LWADC1_AN4,

      LWADC1_AN5,

      LWADC1_AN6,

      LWADC1_AN7,

      LWADC_SIG_NC,

      LWADC_SIG_NC,

      LWADC_SIG_NC,

      LWADC_SIG_NC,

      LWADC_SIG_NC,

      LWADC_SIG_NC,

      LWADC_SIG_NC,

      LWADC_SIG_NC,

   }

};

There are just the channels 0 to 7.

Is this a limitation or can I edit that code in order to enable ADC1SE9 channel for LWADC driver?

Labels (3)
Tags (3)
0 Kudos
1 Solution
1,198 Views
cyborgnegotiato
Senior Contributor II

Hi,

If you need use ADC1SE09 under MQX, you must modify BSP.

Function _bsp_adc_channel_io_init initialize iomux, but you do not need initialize iomux - pin is dedicated. This function must return MQX_OK for this pin, actual implementation of this function do not know about ADC1SE09 and cause our initialization error.

You can find patches in attachment for inspiration :smileywink:

Patch this files:

<MQX_INSTALL_DIR>\mqx\source\bsp\twrvf65gs10_m4\init_gpio.c

<MQX_INSTALL_DIR>\mqx\source\io\lwadc\lwadc_vadc.h

Regards,

Jozef

View solution in original post

0 Kudos
14 Replies
1,198 Views
naoumgitnik
Senior Contributor V

Dear Aaron,

I am not a software person to judge properly but maybe the Vybrid MQX ADC0 and ADC1 thread will help you.

Regards, Naoum Gitnik.

0 Kudos
1,198 Views
abacus
Contributor II

Hi Naoum,

Thank you for your reply. I think that's a different issue, because she is able to init the ADC.

I found this thread A/D Driver Unable to Open Channel where they suggested to add the missing channels in the adc tables of init_gpio.c file.

However, I'm not sure how to do that, since the values defined in that table are the IOMUX number of each ADC channel, for example:

#define LWADC1_AN7 (62)

But the channel I'm using is a dedicated pin.

Aaron

0 Kudos
1,198 Views
naoumgitnik
Senior Contributor V

Dear timesyssupport, may you comment on the customer's request, please?

Thanks in advance, Naoum Gitnik.

0 Kudos
1,198 Views
timesyssupport
Senior Contributor II

Hi Naoum,

I checked the Vybrid reference manual and additionally, Linux source, but could not determine what the definitions for channels 8 and 9 should be. Does the Freescale Vybrid team have any input on this?

Thanks,

Timesys Support

0 Kudos
1,198 Views
naoumgitnik
Senior Contributor V

Dear timesyssupport

I am a bit confused - the VYBRID TOWER SYSTEM MODULE (TWR-VF65GS10) has all 4 dedicated ADC inputs, ADC0SE8, ADC0SE9,  ADC1SE8, and ADC1SE9, connected to the Elevator and TWRPI connectors to be used by other Tower Kit modules (see schematic here - http://cache.freescale.com/files/soft_dev_tools/hardware_tools/schematics/TWR-VF65GS10_SCH.pdf?fpsp=.... - AaronBusca, have you reviewed the TWR-VF65GS10 code available on our web site (provided by TimeSys, so you may ask them in this thread directly as well)?

timesyssupport is it possible that the TWR-VF65GS10 code does not support the above-mentioned 4 ADC inputs although they are used on the schematic?

Regards, Naoum Gitnik.

0 Kudos
1,198 Views
abacus
Contributor II

Hi Naoum,

I tried the example you said.

By default, lwadc_twrvf65gs10_m4 example just tests the ADC connected to the potentiometer unless you define other inputs.

The input I need (ADC1SE9) is this one:

#ifdef BSP_ADC_TWR_AN0

  {"Primary Elevator AN0", BSP_ADC_TWR_AN0 },

#endif

I defined BSP_ADC_TWR_AN0 in user_config.h as follows:

#define BSP_ADC_TWR_AN0                           ADC_INPUT_ADC1_AN9

And I'm getting the same init error:

Failed to initialize ADC input Primary Elevator AN0

Kind regards,

Aaron

0 Kudos
1,198 Views
timesyssupport
Senior Contributor II

Hi Aaron,

We investigated this issue further and below are the findings:

The Vybrid TWR-VF65GS10 board has 4 dedicated ADC inputs (as Naom mentioned) - ADC0SE8, ADC0SE9, ADC1SE8 & ADC1SE9 connected to the elevator and TWRPI connectors.

The Linux Kernel supports all of the above pins and I was successfully able to test ADC0SE5 (via potentiometer), ADC0SE8 and ADC1SE9 in the v3.13 Alpha 1.1 Linux Kernel.

When tried the lwadc_twrvf65gs10_a5 and lwadc_twrvf65gs10_m4 examples in MQX 4.1.1 for Linux with the changes you suggested, I received the same error - 

Logs:

ADC Test for TWRVF65GS10_A5

Monitoring all inputs

T\0xa5\0xb1\0x95\0x91 to initialize ADC input TWRPI Pin#8

Failed to initialize ADC input Primary Elevator AN0

Failed to initialize ADC input Secondary Elevator AN8

Monitoring ADC Inputs

Potentiometer = 02e4 (596 mv)

TWRPI Pin#8 = 0000 (0 mv)

Primary Elevator AN0 = 0000 (0 mv)

Secondary Elevator AN8 = 00a6 (0 mv)

Secondary Elevator AN8 = 023f (0 mv)

Secondary Elevator AN8 = 02e8 (0 mv)

Secondary Elevator AN8 = 0391 (0 mv)

U\0x8d\0xbd\0xb9\0x91\0x85\0xc9\0xe5 Elevator AN8 = 043e (0 mv)

U\0x8d\0xbd\0xb9\0x91\0x85\0xc9\0xe5 Elevator AN8 = 00a8 (0 mv)

Secondary Elevator AN8 = 0236 (0 mv)

Secondary Elevator AN8 = 02e7 (0 mv)

Secondary Elevator AN8 = 038e (0 mv)

, can someone from Freescale MQX team look into the above issue?

Thanks,
Timesys Support

0 Kudos
1,198 Views
karina_valencia
NXP Apps Support
NXP Apps Support

cyborgnegotiator can   you help  to review this case?

0 Kudos
1,198 Views
karina_valencia
NXP Apps Support
NXP Apps Support

Jozef Maslik any update?

0 Kudos
1,199 Views
cyborgnegotiato
Senior Contributor II

Hi,

If you need use ADC1SE09 under MQX, you must modify BSP.

Function _bsp_adc_channel_io_init initialize iomux, but you do not need initialize iomux - pin is dedicated. This function must return MQX_OK for this pin, actual implementation of this function do not know about ADC1SE09 and cause our initialization error.

You can find patches in attachment for inspiration :smileywink:

Patch this files:

<MQX_INSTALL_DIR>\mqx\source\bsp\twrvf65gs10_m4\init_gpio.c

<MQX_INSTALL_DIR>\mqx\source\io\lwadc\lwadc_vadc.h

Regards,

Jozef

0 Kudos
1,198 Views
abacus
Contributor II

Hi Jozef,

That did the job. Thank you.

Aaron

0 Kudos
1,198 Views
karina_valencia
NXP Apps Support
NXP Apps Support

timesyssupport are you available to review this  case and provide your comments?

0 Kudos
1,198 Views
timesyssupport
Senior Contributor II

Hello,

One of our engineers is looking into this issue, and should have an update tonight.

Thanks,

Timesys Support

0 Kudos
1,198 Views
karina_valencia
NXP Apps Support
NXP Apps Support

Perfect, thanks.

0 Kudos