Help with ADC

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

Help with ADC

Jump to solution
1,475 Views
Jairo
Contributor III

Hi, i got a problem with the M52259DEMO board, i can't intialiaze the ADC, and is not a coding problem, it doesn't matter if i use the example config nor a custom configuration; the ADC does'nt start.

In the Debug mode i was able to track down  the failure in the _io_fopen function; there it seems that the MQX kernel just detects two devices in the IO_DEVICES struct listed here

 

static FILE_PTR  fd_adc, fd_ch = NULL;    //Apuntadores para el ADC y para el Canal del ADCconst ADC_INIT_STRUCT adc_init = {    ADC_RESOLUTION_DEFAULT,     /* resolucion del ADC*/};const ADC_INIT_CHANNEL_STRUCT adc_ch_param = {    ADC_SOURCE_AN0,    //Configura lo que se va a leer     ADC_CHANNEL_MEASURE_LOOP | ADC_CHANNEL_START_NOW,    10,            /* numero de muestras en una secuencia */    0,             /* Offset de tiempo desde el trigger en ns */    50000,         /* perioso en us (50ms) */    0x10000,       /* Rango de escala del resultado (no usado) */    1,             /* Tamaño del buffer circular (sample count) */    ADC_TRIGGER_1  /* ID del trigger logico que inicia este canal del ADC */};/* *  Configurar ADC para que lea los valores en potenciometro y acelerometro */   void InitADC(void) {    fd_adc = fopen("adc:", (const char*)&adc_init);    if (NULL == fd_adc)     {            printf("\nFallo la inicializacion del ADC\n");        return;     }        fd_ch = fopen("adc:0", (const char*)&adc_ch_param);    if (fd_ch == NULL)     {            printf("\nadc:0 Error al abrir el canal del ADC\n");        return;    }}

 

 The IO_DEVICE struct that i've found in the Kernel_data in _io_fopen is:

 

IO_DEVICE --address:     0x00000000   Identifier:  "/" --address:     0x20000A78   Identifier:  "ttya:" --address:     0x20000C10   Identifer:   "gpio:" --address:     0x20000330   Identifier:  "ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ"

 

 and that's all the devices, so when i try to access the "adc:" returns error because the function did't found such device. Any idea about how can i initialiaze the ADC? Thanks in advance.

 

 

0 Kudos
1 Solution
394 Views
Jairo
Contributor III

i recompiled the BSP files,apparently just modify the files don't make change in the code that would be downloaded to the target. Recompiling with the corresponding modifications and making a new project file was the solution.

 

View solution in original post

0 Kudos
1 Reply
395 Views
Jairo
Contributor III

i recompiled the BSP files,apparently just modify the files don't make change in the code that would be downloaded to the target. Recompiling with the corresponding modifications and making a new project file was the solution.

 

0 Kudos