Hello,
I try to use example of lwadc on MQX 4.0.2 (Timesys) on TWR_VF6XX. I follow the Timesys "How To " for building MQX BSP and PSP. I'm able to launch mcc-pingpong demo and it works on my board.
However, I need to do some measure using ADC. I found the example "lwadc_twrvf65gs10_m4", It build without error but when I launch it it seems it crashes in monitor_potentiometer function when calling "_lwadc_get_attribute(...,LWADC_REFERENCE, &reference))" .
I comment this function, it doesn't crash but the adc's value doesn't change when I moove the potentiometer:
Here is a sample of my code :
input = BSP_ADC_POTENTIOMETER;
_lwadc_init_input(&potentiometer,input);
/* We want to change the default scaling of the potentiometer to return a percent instead of milli-volts.
printf("Rotate potentiometer. Test will run until readings range from 10%% to 90%% \n");
while(1) {
//read ADC value
_lwadc_read_raw(&potentiometer, &percent); printf("potentiometer = %d\n",percent); _lwadc_wait_next(&potentiometer); }
With this code, i get on my serial :
potentiometer = 756
potentiometer = 756
potentiometer = 756
Do I forgot something?
note : the potentiometer is working fine. I test it with multimeter.
Solved! Go to Solution.
Hi Jemery,
I just tested the example but in the latest MQX version, and it is working with no problems.
Could you try with that version?
Regards,
Alejandro
Hi,
I wonder if you are initialising the lwadc.
_lwadc_init(&BSP_DEFAULT_LWADC_MODULE);
I do not see the above line in your code.
Best Regards,
Alejandro
Hi,
The init of the lwadc is called in the file "init_bsp.c" :
#if BSPCFG_ENABLE_LWADC
#if BSPCFG_ENABLE_LWADC0
_lwadc_init(&lwadc0_init);
#endif
#if BSPCFG_ENABLE_LWADC1
_lwadc_init(&lwadc1_init);
#endif
#endif
Do I need to free the adc module on Linux to use it on MQX ?
Or maybe, I have to change the MQX version ?
Hi,
Have you tried the lwad example found at mqx/examples/ folder?
Hi Alejandro,
Yes, the first thing I tried was the lwadc example. I built it with no error, launch it from linux console using mqxboot and the program start but block without printing any value.
I've found that it was blocking when calling _lwadc_get_attribute(...,LWADC_REFERENCE, &reference)) or _lwadc_set_funtion(LWADC_REFERENCE,value).
In the example I was not able to SET or GET the LWADC_REFERENCE parameter. So, my code is the example in which I've removed all _lwadc_set_funtion() calls and i made a read_raw() instead of read()
Hi Jemery,
I just tested the example but in the latest MQX version, and it is working with no problems.
Could you try with that version?
Regards,
Alejandro
Hi Alejandro,
I tested with the latest MQX version (4.1.2) and it works !
But now it's the mcc-pingpong which doesn't work because functions has been modified on the m4 processor with the latest MQX version but not on a5 processor (Linux) but I saw in this post linux libmcc that they working on it.
I except that it will be ready as soon as possible.
Thank you for your help Alejandro.