我最近购买了一个 nrf52840 USB 加密狗;但是,我对没有 IDE 和一般北欧产品的编程很陌生。我没有从我的程序中得到我期望的结果,或者根本没有得到任何结果,尽管我不确定我的问题是源于我的程序还是我编写的链接器脚本。任何帮助,将不胜感激。
编辑:我已经编辑了链接器脚本以包含所有(我希望)所需的材料。我还发布了启动代码。
@Lundin 我正在使用 GCC 进行编译,并使用 NRF Connect 通过 USB 对芯片进行编程。到目前为止,我正在尝试时钟设置,但没有运气,但我在数据表中注意到有一个 32 MHz 内部振荡器,如果调用高速时钟并且外部振荡器没有打开,它应该会打开。
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;
}
启动.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