I've recently purchased an nrf52840 usb dongle; however, I'm new to programming without an IDE and with Nordic products in general. I'm not getting the results I expect from my program, or indeed any results at all, though I'm not sure if my problem stems from my program or the linker script I wrote. Any help would be appreciated.
Edit: I've edited the linker script to contain all (I hope) required material. I've also posted the start-up code.
@Lundin I'm using GCC to compile and NRF Connect to program the chip via USB. I'm currently experimenting with the clock settings with no luck so far, but I have noticed in the datasheet that there is a 32 MHz internal oscillator that will supposedly turn on if the high speed clock is called and the external oscillator is not on.
LEDTest.c
// RGB LED at pins G-22,R-23,B-24
#define GPIO_BASE_ADDRESS 0x50000000
#define OUTSET_ADDRESS_OFFSET 0x508 // 1's written to this register set corresponding pins (HIGH). 0's have no effect.
#define DIRSET_ADDRESS_OFFSET 0x518 // 1's written to this register setup corresponding pins as OUTPUT. 0's have no effect.
volatile unsigned long * setupOutputPins = (volatile unsigned long *)GPIO_BASE_ADDRESS + DIRSET_ADDRESS_OFFSET;
volatile unsigned long * ledOn = (volatile unsigned long *)GPIO_BASE_ADDRESS + OUTSET_ADDRESS_OFFSET;
void main(void){
*setupOutputPins = 0x01C00000; // Make pins 22, 23, and 24 OUTPUT
for(;;){
*ledOn = 0x00400000; // Make pin 22 HIGH
}
}
LEDTest.ld
ENTRY (main)
MEMORY{
FLASH (rx) : ORIGIN = 0x1000, LENGTH = 0xFF000
RAM (rwx) : ORIGIN = 0x20000008, LENGTH = 0x3FFF8
}
SECTIONS{
. = 0x1000;
.text : {
*(vectors);
*(.text);
}
.rodata : {
*(.rodata);
}
flash_sdata = .;
. = 0x20000008;
ram_sdata = .;
.data : AT (flash_sdata){
*(.data);
}
ram_edata = .;
data_size = ram_edata - ram_sdata;
sbss = .;
.bss : {
*(.bss)
}
ebss = .;
bss_size = ebss - sbss;
}
startup.s
.section "vectors"
reset: b start
undef: b undef
swi: b swi
pabt: b pabt
dabt: b dabt
nop
irq: b irq
fiq: b fiq
.text
start:
ldr r0, =flash_sdata
ldr r1, =ram_sdata
ldr r2, =data_size
cmp r2, #0
beq init_bss
copy:
ldrb r4, [r0], #1
strb r4, [r1], #1
subs r2, r2, #1
bne copy
init_bss:
ldr r0, =sbss
ldr r1, =ebss
ldr r2, =bss_size
cmp r2, #0
beq init_stack
mov r4, #0
zero:
strb r4, [r0], #1
subs r2, r2, #1
bne zero
init_stack:
ldr sp, =0x20040000
bl main
stop: b stop
There are a few resources by Nordic that help you get started with nRF52840 development. Please see the following links:-
Please note that you can still use an IDE to write your applications, but as you probably already know, you then have to use Nordic's tools to flash the app onto the dongle. For more information on IDE usage, please see this:-
I hope this helps.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.