This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Examples for nRF52840 Dongle ADC Reading

Hello,

I am using nRF52840 Dongle and I want to use AIN0 pin for reading a sensor data. I was using PIC for this kind of project(C Programming)  before nRF52840. Here my questions;

1) I am new at programming nRF52840 and i need some examples for Analog Digital Converter. So how can i make ADC configuration basically ? I tried to understand SAADC example but it uses timer interrup. I need to use it without any interrupt. 

2) Which functions are using for getting value between 0-2048(for 11 bits res.) ?  In examples used 2 dimensions array for storage value of ADC results. I just want to store it an integer.

If we compare nRF52840  with PIC, nRF52840 is very complicate for me and it's libraries are not using basic C language. So i need some basic examples.

Thank you :)

Parents
  • I am new at programming nRF52840

    In that case, you should certainly be starting with the nRF52840-DK rather than the dongle.

    As the name suggests, the DK is specifically designed for Development use - not least because it comes with an on-board debugger.

    Nearly all of the SDK examples focus on the DKs.

    The dongle is great as a cheap platform once you have a working application - but the DK is the place to do learning & development.

    If we compare nRF52840  with PIC, nRF52840 is very complicate

    Which particular "PIC" are you talking about?

    The nRF52840 is a complete System on a Chip - "SoC" - with a high-performance, 32-bit, ARM Cortex-M4F CPU plus a complete radio susbsystem plus some pretty advanced peripherals.

    That is obviously going to be a lot more complicated that a simple little 8-bit microcontroller!

    But the basic principles remain the same.

    it's libraries are not using basic C language

    The libraries use standard 'C'.

  • Well, i tried to get DK but, because of customs duty it costs me about 250$-300$. Unfortunately, I must make do with dongle for a while. By the way i found some codes in Nordic Devzone. Is this work for Dongle? I think this is the basic one. Thanks for your reply.

    #include "nrf.h"
    #include <stdbool.h>
    #include <stdint.h>
    #include <stdio.h>
    #include "nrf_drv_adc.h"
    #include "nordic_common.h"
    #include "boards.h"
    #include "nrf_log.h"
    #include "app_error.h"
    #include "nrf_delay.h"
    #include "app_util_platform.h"
    
    
    static nrf_adc_value_t       adc_value; /**< ADC buffer. */
    static nrf_drv_adc_channel_t m_channel_config = NRF_DRV_ADC_DEFAULT_CHANNEL(NRF_ADC_CONFIG_INPUT_2); 
    
    /**
     * @brief Function for main application entry.
     */
    int main(void)
    {
        UNUSED_RETURN_VALUE(NRF_LOG_INIT());
        NRF_LOG_PRINTF("ADC example\r\n");
    
        while (true)
        {
            nrf_drv_adc_sample_convert(&m_channel_config,&adc_value);
            NRF_LOG_PRINTF("ADC buffer: %d\r\n",adc_value);
            nrf_delay_ms(100);
        }
    }
    /** @} */

  • I must make do with dongle for a while.

    So do you have a J-Link? 

    As noted, this is a complex part - trying to develop without a debugger is not advised!

    (other debuggers are available)

    Is this work for Dongle?

    See:

    https://devzone.nordicsemi.com/f/nordic-q-a/43760/adapting-the-blinky-example-from-the-nrf52840-dk-to-the-nrf52840-dongle/171340#171340

    So it's just the same as porting code for a PIC on one board to the same PIC on a different board - it's just the external hardware dependencies which need attention.

  • No, I have no J-Link  but i have embedded ST-Link on my STM32F429 Development Kit. I connected ST-Link's GND,VDD,SWDIO,SWDCLCK pins to nRF52840 dongle for programming it via uKeil. It didn't work. I didn't get any error when i was flashing blinky example but it didn't work Disappointed

Reply Children
No Data
Related