element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • About Us
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Arduino
  • Products
  • More
Arduino
Arduino Forum How to upload code in nRF52840 DK using Arduino IDE?
  • Blog
  • Forum
  • Documents
  • Quiz
  • Events
  • Polls
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join Arduino to participate - click to join for free!
Actions
  • Share
  • More
  • Cancel
Forum Thread Details
  • Replies 16 replies
  • Subscribers 385 subscribers
  • Views 6352 views
  • Users 0 members are here
  • flash programmer
  • pin
  • arduino ide
  • nrf
Related

How to upload code in nRF52840 DK using Arduino IDE?

KKaushik
KKaushik over 2 years ago

I'm trying to flash code in nRF52840 DK through Arduino IDE, but it kept failing.

I could only burn the bootloader with Arduino IDE.

image

image

Setting of board here:

image

Can anyone help me with this? Am I missing something in the setting to flash code to nRF52840 DK using Arduino IDE?

I can do it successfully with nRF52 Programmer, using the HEX file but the code has no effect on the nRF52DK. The below-mentioned Blink Code:

/*
  Blink
  Turns on an LED on for one second, then off for one second, repeatedly.

  Most Arduinos have an on-board LED you can control. On the UNO, MEGA and ZERO 
  it is attached to digital pin 13, on MKR1000 on pin 6. LED_BUILTIN takes care 
  of use the correct LED pin whatever is the board used.
  If you want to know what pin the on-board LED is conn
  ected to on your Arduino model, check
  the Technical Specs of your board  at https://www.arduino.cc/en/Main/Products
  
  This example code is in the public domain.

  modified 8 May 2014
  by Scott Fitzgerald
  
  modified 2 Sep 2016
  by Arturo Guadalupi
*/

#include <Arduino.h>
#include <Adafruit_TinyUSB.h> // for Serial

#define LED_BUILTIN PIN_LED2
// the setup function runs once when you press reset or power the board
void setup() {
  // initialize digital pin LED_BUILTIN as an output.
  pinMode(LED_BUILTIN, OUTPUT);
}
     
// the loop function runs over and over again forever
void loop() {
  digitalToggle(LED_BUILTIN); // turn the LED on (HIGH is the voltage level)
  delay(1000);                // wait for a second
}

How to access nRF52840DK pins in Arduino IDE, direct pin number doesn't work clearly?

  • Sign in to reply
  • Cancel

Top Replies

  • KKaushik
    KKaushik over 2 years ago in reply to BigG +2
    After your above-detailed answer, I tried to follow exactly the same. Using the bottom right USB, hold Button1 then press/release Reset, then release button1. Still no detection of the serial port. I…
  • BigG
    BigG over 2 years ago +1
    Do you have the correct bootloader: https://github.com/adafruit/Adafruit_nRF52_Bootloader/releases Was the board in DFU mode... according to github page: https://github.com/adafruit/Adafruit_nRF52_Bootloader…
  • mayermakes
    mayermakes over 2 years ago in reply to KKaushik +1
    not while setting code, you have to keep the button pressed during reset.
  • KKaushik
    KKaushik over 2 years ago in reply to BigG

    When I connect to the right bottom USB one, there is no port detection.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • KKaushik
    KKaushik over 2 years ago in reply to KKaushik

    Though it runs blinky code which I flashed through VS Code using nRF Connect. So it's getting power with the right one too. Just not the J-link port is visible, which is visible only with the left USB.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • BigG
    BigG over 2 years ago in reply to KKaushik

    Yes that is correct. You will get no port detection until you correctly enter DFU mode.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • KKaushik
    KKaushik over 2 years ago in reply to BigG

    After your above-detailed answer, I tried to follow exactly the same. Using the bottom right USB, hold Button1 then press/release Reset, then release button1. Still no detection of the serial port.

    I tried even pressing Button1 while power-off and turning power-on then releasing Button1, but still no detection using Bottom Right USB

    Then I went back to using Left Serial Port: I tried the same procedure but after a successful Bootloader Burn, while uploading code showed the same error.

    Timed out waiting for acknowledgement from device.
    Sending DFU init packet


    So, I have started using the bootloader for Adafruit Bluefruit nRF52, as I have written all code on the basis of that.

    I found one way which works 100%, here how it goes

    1. "Erase ALL" using nRF Programmer

    image

    2. Select board: Adafruit Feather nRF52832 & Burn Bootloader

    image

    image

    3. Upload Code

    image

    And it works just fine 

    image

    #define LED_BUILTIN1          2
    // the setup function runs once when you press reset or power the board
    void setup() {
      // initialize digital pin LED_BUILTIN as an output.
      Serial.begin(115200);
      pinMode(LED_BUILTIN1, OUTPUT);
    }
    
    // the loop function runs over and over again forever
    void loop() {
      digitalWrite(LED_BUILTIN1, HIGH);   // turn the LED on (HIGH is the voltage level)
      delay(1000);                       // wait for a second
      digitalWrite(LED_BUILTIN1, LOW);    // turn the LED off by making the voltage LOW
      delay(1000);                       // wait for a second
      
      //Serial.println(Serial.read());
      Serial.println("Hellow4");
    }

    The only issue with this use on nRF52DK is pin mapping.

    When I checked the variant.h for Nordic nRF52DK, LED1 connected to pin 13. So I changed LED-BUILTIN to 13 and it works fine.

    I tried the same just with the board: Nordic nRF52 DK, bootloader burn successfully but the uploading code gives the same timeout error. 

    So I'll stick to this. Now I need help with how can I upload the same bootloader to my custom PCB based on nRF52810.

    Using nRF52DK as J-Link connected to my custom PCB (SWD Connector), I tried to upload the bootloader after "Erase All", but it shows this error

    image

    Is there any solution to this? So I can upload Adafruit Feather nRf52832 Bootloader to nRF52810?

    • Cancel
    • Vote Up +2 Vote Down
    • Sign in to reply
    • Cancel
  • BigG
    BigG over 2 years ago in reply to KKaushik
    KKaushik said:
    So I'll stick to this. Now I need help with how can I upload the same bootloader to my custom PCB based on nRF52810.

    Yes, the bootloader should be ok, but then for your sketch you should probably use a new board definition which defines the correct flash and memory sizes for the nRF52810.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • KKaushik
    KKaushik over 2 years ago in reply to BigG
    BigG said:
    Yes, the bootloader should be ok

    No, it shows an error while uploading the bootloader using nrfjprog.

    image

    Tried with the latest bootloader: feather_nrf52832_bootloader-0.7.0_s132_6.1.1.hex from https://github.com/adafruit/Adafruit_nRF52_Bootloader/releases

    But the address 0x00074000 does not map to a known memory. I think the issue is with the bootloader.

    How can I define a new board definition using the nRF52832 board?

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
<
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube