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?
Solved! Go to Solution.
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
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.
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
Dear timesyssupport, may you comment on the customer's request, please?
Thanks in advance, Naoum Gitnik.
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
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.
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
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)
karinavalencia, can someone from Freescale MQX team look into the above issue?
Thanks,
Timesys Support
cyborgnegotiator can you help to review this case?
Jozef Maslik any update?
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
Hi Jozef,
That did the job. Thank you.
Aaron
timesyssupport are you available to review this case and provide your comments?
Hello,
One of our engineers is looking into this issue, and should have an update tonight.
Thanks,
Timesys Support
Perfect, thanks.