Post Go back to editing

BF506F EZ-Kit adi_dev_open() problem: opening ADC device and UART device handle

Hello,

i'm new to DSPs and i want to use the adi-Libraries instead of editing registers. With all the given examples i tried to figure out, how i have to handle the library functions.

I want to use the internal ADC to sample a signal and then send the digital values via UART to the computer.

I used the example codes and ended up with two adi_dev_open() lines, each followed by a adi_dev_control() function. One adi_dev_open() is for the ADC module and one for the UART device. If i open only one of these devices, so there's only one adi_dev_open(), everything is fine. But if i have a second adi_dev_open(), this function returns not zero, but something like 0x03000040. What does this mean? Where is the problem? Has it something to do with the parameter: adi_dev_ManagerHandle?

Thank you! It's for my master thesis.

Here's the problematic code snippet:

/* open the UART driver */
    nResult = adi_dev_Open(  adi_dev_ManagerHandle,          /* Dev manager Handle                   */
                             &ADIUARTEntryPoint,             /* Entry point for Interrupt driven UART*/
                             UART_DEVICE_NUMBER,             /* Device number                        */
                             NULL,                           /* No client handle                     */
                             &UARTDriverHandle,              /* Location to store UART driver handle */
                             ADI_DEV_DIRECTION_BIDIRECTIONAL,/* Data Direction                       */
                             NULL,                           /* Handle to DMA Manager                */
                             hDcbManager,                 /* Handle to callback manager           */
                             UARTCallback);                  /* Callback Function                    */
   
    /* pass UART configuration table to the driver */
    nResult = adi_dev_Control(UARTDriverHandle, ADI_DEV_CMD_TABLE, (void*)UARTConfigTable);
    
    /* Open BF506F ADC Device */
    nResult = adi_dev_Open(adi_dev_ManagerHandle,
                           &ADI_BF506ADC1_EntryPoint,
                           0,
                           NULL,
                           &hAdcDevice,
                           ADI_DEV_DIRECTION_INBOUND,
                           adi_dma_ManagerHandle,
                           hDcbManager,
                           AdcCallback);

    /* Configure ADC driver and ACM/SPORT Device registers */
    nResult = (adi_dev_Control (hAdcDevice,
                                ADI_DEV_CMD_TABLE,
                                (void *) &aoAdcConfig[0]));

  • Hi,

    It is most likely that you are not allocating enough memory to one of the Services (Device Manager, would be my first suspicion).

    Most of the examples include "adi_ssl_Init.c" and "adi_ssl_Init.h" files, take a look in the header and you'll see numbers defined for the number of interrupts, devices, etc. Try adjusting these to make larger allocations in the services to accommodate the additional device.

    If you need more help, can you post a complete example?


    Thanks,
    Craig.

  • As a follow up, the valid enumerations for the for return values from adi_dev() calls are listed in "...\Blackfin\Include\drivers\adi_dev.h". These codes are extensible by individual drivers, so you should also check the header file for the failing device to see what the return code indicates.

    Regards,

    Craig.

  • Hi Max,

    Great! Thanks for letting me know that worked. The ADC driver will use an underlying SPORT device driver, so it can be easy to under-resource when using these as the single ADC Device Driver actually uses two devices; the ADC and its underlying SPORT device .

    The documentation for the individual device drivers, which can be found at "...\Blackfin\docs\" detail any lower-level drivers used by the device.

    Regards,

    Craig.

  • Thank you very much for the quick answers Craig! Your suspicion was right!

    I changed the number of device drivers from 2 to 3. I thougth i have only 2 device drivers (ADC and UART) and that it would be ok. With the number of 3 it works!

    Regards,

    Max.