DA14585 ADC Setup/Reading

Hi Support,

I have a few quick questions about using the ADC of the DA14585. I have traditionally been using the DA14531 and have posted many support threads about ADC functionality. By recommendation of this support thread, I have acquired a DA14585 QFN development kit for testing. 

First, I set up the DA14585 using the General Purpose ADC for the DA14531 guide after doing the Initial Project setup. I am wondering now how to fully set it up, since there are errors of course since the guide relies on you using the DA14531.

First I have changed the adc_cfg variable within gpadc_read(), since based on the adc_58x.h file it only has parameters mode, input, attn, and sign. I have currently set up my adc_cfg like this:

adc_config_t adc_cfg = {
    .mode = ADC_INPUT_MODE_SINGLE_ENDED,
    .input = ADC_INPUT_SE_P0_0, // Can use P0_0 to P0_3
    .attn = true,
    .sign = false
};

This seems to compile fine without crashes. The issue I have is with the gpac_sample_to_mv() function when you calculate a reference voltage. Keil says GP_ADC_ATTN is not found, which I can confirm is missing in the adc_58x.h file.

What adjustments need to be made to gpac_sample_to_mv() to use it with the DA14585? Is there skeleton code for ADC functionality with DA14585 like there is for DA14531 (the guide linked above)? The adc_58x.h file seems to show that DA14585 has way less functionality/customizability of the ADC compared to DA14531, is this true?

Thanks!

  • Hi Trevor, 

    Thanks for your question. The DA14585 ADC block is slightly different from the DA14531 one. I would recommend checking the datasheets in order to compare the HW blocks. 

    The tutorial is very helpful only for DA14531. Unfortunately, there is no tutorial from DA14585

    The SDK 6.0.14 includes an ADC example which showcases how to read the battery level. It can be found on this SDK path : 6.0.16.1144\projects\target_apps\peripheral_examples\adc\batt_lvl

    There are different build configurations for DA14531, DA14585 and DA14586. Build the example for DA14585 and check how the ADC can be configured. As mentioned d correctly in the initial description, there are different libraries for DA14531 and DA14585/6.

    Regards, 

    PM_Renesas

  • Hi PM_Renesas,

    Thank you for the info. I believe I have the ADC configured now and understand the differences in functions between DA14531 and DA14585 based on their adc code in the SDK.

    My new question is about the pin configuration of the DA14585. In the Initial Project Configuration in the ADC tutorial, they use these pins for the DA14531:

    #define SPI_EN_PORT                     GPIO_PORT_0
    #define SPI_EN_PIN                      GPIO_PIN_1
    #define SPI_CLK_PORT                    GPIO_PORT_0
    #define SPI_CLK_PIN                     GPIO_PIN_4
    #define SPI_DO_PORT                     GPIO_PORT_0
    #define SPI_DO_PIN                      GPIO_PIN_0
    #define SPI_DI_PORT                     GPIO_PORT_0
    #define SPI_DI_PIN                      GPIO_PIN_3

    I understand that the DA14585 is like going to be different. Based on user_periph_setup.h it appears the defaults for non-DA14531 (so 585/586) is:

        #define SPI_EN_PORT             GPIO_PORT_0
        #define SPI_EN_PIN              GPIO_PIN_3
        #define SPI_CLK_PORT            GPIO_PORT_0
        #define SPI_CLK_PIN             GPIO_PIN_0
        #define SPI_DO_PORT             GPIO_PORT_0
        #define SPI_DO_PIN              GPIO_PIN_6
        #define SPI_DI_PORT             GPIO_PORT_0
        #define SPI_DI_PIN              GPIO_PIN_5

    I am running into breakpoint errors related to pin mappings overlapping with one another, and I am not sure how to adjust the SPI pins so that this does not occur. I also have changed the UART pin from 4 to pin 5 as described in the Initial Project Configuration description. I don't care about UART functionality for my project, can I remove it being assigned at all, or is there a random pin I could put it on so that it doesn't conflict with my other pins? 

    I have tried a few combination of pins and have removed the ADC pins entirely from the code and I still run into issues with pin mapping overlap. Is there somewhere these pins are better described? In the 14585 datasheet I can't see to locate where I can see more about SPI's usage of pins.

    Thanks!

  • Hi trevorsc,

    From the snippet you shared it appears that you are defining the SPI_DIN_PIN as GPIO_PIN_5. Setting this pin for use with the UART too will cause conflict because of overlapping. Usually with the DA14585 the UART2 TX pin is set to be pin 0_4 and SPI pins are set in the way that you shared above (e.g. see the prox_reporter example as a reference which  can be found on this SDK path:

    6.0.16.1144\projects\target_apps\ble_examples\prox_reporter

    If you don't want to use the UART functionality you can remove the definition for the pin but also make sure that you have CFG_PRINTF undefined in file da1458x_config_basic.h.

    As can be seen in the DA14585 datasheet

    https://www.renesas.com/eu/en/document/dst/da14585-datasheet?language=en&r=1600291 

    page 119 only pins 0_0, 0_1, 0_2, 0_3 can be used with the ADC. You will need to make sure that the ADC pins that you are using don't overlap with the SPI pins.

    SPI pins can be mapped to any GPIOs on the DA14585 as long as they are not used by some other peripheral. The above mentioned(default) setting is convenient as looking at the pro development kit schematic 

    the green lettering on the right side of the J1 header corresponds to the DA14585 pins. So this enables the user to just have 4 jumpers to connect the DA14585 SPI to the SPI flash that is on the motherboard. 

    Please let us know if you have more questions or if your use case was misunderstood.

    Best regards,
    AA_Renesas

  • Hi AA_Renesas,

    Thanks for the detailed response!

    I've undefined the CFG_PRINTF now and commented out the UART definitions.

    I'm still running into my breakpoint error for pin mappings overlapping. Here is the section of my user_periph_setup.h that has the pin maps:

    /****************************************************************************************/
    /* LED configuration                                                                    */
    /****************************************************************************************/
    #if defined (__DA14531__)
        #define GPIO_LED_PORT           GPIO_PORT_0
        #define GPIO_LED_PIN            GPIO_PIN_9
    #else
        #define GPIO_LED_PORT           GPIO_PORT_1
        #define GPIO_LED_PIN            GPIO_PIN_1
    #endif
    
    /****************************************************************************************/
    /* SPI configuration                                                                    */
    /****************************************************************************************/
    // Define SPI Pads
    #if defined (__DA14531__)
        #define SPI_EN_PORT             GPIO_PORT_0
        #define SPI_EN_PIN              GPIO_PIN_1
        #define SPI_CLK_PORT            GPIO_PORT_0
        #define SPI_CLK_PIN             GPIO_PIN_4
        #define SPI_DO_PORT             GPIO_PORT_0
        #define SPI_DO_PIN              GPIO_PIN_0
        #define SPI_DI_PORT             GPIO_PORT_0
        #define SPI_DI_PIN              GPIO_PIN_3
    
    #elif !defined (__DA14586__) // DA14585 Section
        // Default SPI Assignments
        #define SPI_EN_PORT             GPIO_PORT_0
        #define SPI_EN_PIN              GPIO_PIN_3
        #define SPI_CLK_PORT            GPIO_PORT_0
        #define SPI_CLK_PIN             GPIO_PIN_0
        #define SPI_DO_PORT             GPIO_PORT_0
        #define SPI_DO_PIN              GPIO_PIN_6
        #define SPI_DI_PORT             GPIO_PORT_0
        #define SPI_DI_PIN              GPIO_PIN_5
    #endif
    
    /***************************************************************************************/
    /* Production debug output configuration                                               */
    /***************************************************************************************/
    #if PRODUCTION_DEBUG_OUTPUT
    #if defined (__DA14531__)
        #define PRODUCTION_DEBUG_PORT   GPIO_PORT_0
        #define PRODUCTION_DEBUG_PIN    GPIO_PIN_11
    #else
        #define PRODUCTION_DEBUG_PORT   GPIO_PORT_2
        #define PRODUCTION_DEBUG_PIN    GPIO_PIN_5
    #endif
    #endif
    
    
    // ADC Configuration
    #define ADC_INPUT_PORT                  GPIO_PORT_0
    #define ADC_INPUT_PIN                   GPIO_PIN_2  // 2 is not in used by anything else
    

    As far as I can see, unless something obvious has snuck by, I don't believe I have any overlapping pin configurations.

    I am uncertain of the differences it would imply, but I think it could be useful to mention that I am using a DA14585-00ATDEVKT-P Development Kit - Pro. I am not sure what the difference is precisely with the motherboard on this system as opposed to other variants, and I am still going through the datasheets to figure it out.