I am trying to program a fresh KV10 mcu, but can't get things to work. I'm programming the chip on my own PCB using the KV10 Freedom Dev Board. I made sure to cut the trace and isolate the clock pin on the SWD connection so I think it's good to program. One thing I noticed was that the reset pin was being pulled low internally, despite a 10k pull up resistor. I added a 47uF cap to the power rail to ensure correct POR and the mcu became responsive to programming, but the reset pin is still pulled low. Now when I try to flash and debug the mcu in KDS I can see in the console that it connects, but it fails to read values and begin debugging.
What could be causing this?
Here is the console output:
SEGGER J-Link GDB Server V5.10n Command Line Version
JLinkARM.dll V5.10n (DLL compiled Feb 19 2016 18:39:11)
-----GDB Server start settings-----
GDBInit file: none
GDB Server Listening port: 2331
SWO raw output listening port: 2332
Terminal I/O port: 2333
Accept remote connection: localhost only
Generate logfile: off
Verify download: on
Init regs on start: on
Silent mode: off
Single run mode: on
Target connection timeout: 0 ms
------J-Link related settings------
J-Link Host interface: USB
J-Link script: none
J-Link settings file: none
------Target related settings------
Target device: MKV10Z16xxx7
Target interface: SWD
Target interface speed: 30kHz
Target endian: little
Connecting to J-Link...
J-Link is connected.
Firmware: J-Link OpenSDA 2 compiled Oct 13 2015 12:10:56
Hardware: V1.00
S/N: 621000000
Checking target voltage...
Target voltage: 3.30 V
Listening on TCP/IP port 2331
Connecting to target...WARNING: T-bit of XPSR is 0 but should be 1. Changed to 1.
Connected to target
Waiting for GDB connection...Connected to 127.0.0.1
Reading all registers
ERROR: Can not read register 0 (R0) while CPU is running
ERROR: Can not read register 1 (R1) while CPU is running
ERROR: Can not read register 2 (R2) while CPU is running
ERROR: Can not read register 3 (R3) while CPU is running
ERROR: Can not read register 4 (R4) while CPU is running
ERROR: Can not read register 5 (R5) while CPU is running
ERROR: Can not read register 6 (R6) while CPU is running
ERROR: Can not read register 7 (R7) while CPU is running
ERROR: Can not read register 8 (R8) while CPU is running
ERROR: Can not read register 9 (R9) while CPU is running
ERROR: Can not read register 10 (R10) while CPU is running
ERROR: Can not read register 11 (R11) while CPU is running
ERROR: Can not read register 12 (R12) while CPU is running
ERROR: Can not read register 13 (R13) while CPU is running
ERROR: Can not read register 14 (R14) while CPU is running
ERROR: Can not read register 15 (R15) while CPU is running
ERROR: Can not read register 16 (XPSR) while CPU is running
ERROR: Can not read register 17 (MSP) while CPU is running
ERROR: Can not read register 18 (PSP) while CPU is running
ERROR: Can not read register 24 (PRIMASK) while CPU is running
ERROR: Can not read register 25 (BASEPRI) while CPU is running
ERROR: Can not read register 26 (FAULTMASK) while CPU is running
ERROR: Can not read register 27 (CONTROL) while CPU is running
Read 4 bytes @ address 0x00000000 (Data = 0xFFFFFFFF)
Target interface speed set to 30 kHz
Resetting target
Halting target CPU...
...Target halted (PC = 0xFFFFFFFE)
R0 = FFFFFFFF, R1 = FFFFFFFF, R2 = FFFFFFFF, R3 = FFFFFFFF
R4 = FFFFFFFF, R5 = 01BFF327, R6 = FBB7F77F, R7 = 07DFFF1E
R8 = FF8DDDBF, R9 = 007D81D9, R10= 03FE1F78, R11= 07FB7F5C
R12= FFFE9B15, R13= 00000BB8, MSP= 7FFFFFFC, PSP= 00000BB8
R14(LR) = 3FFFFFFC, R15(PC) = FFFFFFFE
XPSR F1000000, APSR F0000000, EPSR 01000000, IPSR 00000000
CFBP 1FFFF6B0, CONTROL 1F000000, FAULTMASK FF0000, BASEPRI F600, PRIMASK B0
Reading all registers
Select auto target interface speed (1429 kHz)
Flash breakpoints enabled
Semi-hosting enabled (Handle on BKPT)
Wrong client mask. Semihosting I/O not changed.
Downloading 192 bytes @ address 0x00000000 - Verified OK
Downloading 16 bytes @ address 0x00000400 - Verified OK
Downloading 668 bytes @ address 0x00000410 - Verified OK
Downloading 8 bytes @ address 0x000006AC - Verified OK
Downloading 4 bytes @ address 0x000006B4 - Verified OK
Downloading 4 bytes @ address 0x000006B8 - Verified OK
Downloading 100 bytes @ address 0x000006BC - Verified OK
WARNING: CPU could not be halted
ERROR: Failed to measure CPU clock frequency
Failed to halt CPU for clock frequency detection!
Writing register (PC = 0x000004e8)
WARNING: Failed to read memory @ address 0x000004E8
Read 2 bytes @ address 0x0000059C (Data = 0xFFFF)
Read 2 bytes @ address 0x0000059C (Data = 0xFFFF)
WARNING: CPU did not halt after reset.
WARNING: T-bit of XPSR is 0 but should be 1. Changed to 1.
WARNING: T-bit of XPSR is 0 but should be 1. Changed to 1.
WARNING: CPU could not be halted
Resetting target
Halting target CPU...
WARNING: CPU could not be halted
Read 2 bytes @ address 0x0000059C (Data = 0xFFFF)
WARNING: Failed to read memory @ address 0x0000059C
ERROR: Can not read register 24 (PRIMASK) while CPU is running
ERROR: Can not read register 25 (BASEPRI) while CPU is running
ERROR: Can not read register 26 (FAULTMASK) while CPU is running
ERROR: Can not read register 27 (CONTROL) while CPU is running
ERROR: Can not read register 20 (CFBP) while CPU is running
ERROR: Can not read register 23 (IPSR) while CPU is running
ERROR: Can not read register 22 (EPSR) while CPU is running
ERROR: Can not read register 21 (APSR) while CPU is running
ERROR: Can not read register 16 (XPSR) while CPU is running
ERROR: Can not read register 15 (R15) while CPU is running
ERROR: Can not read register 14 (R14) while CPU is running
ERROR: Can not read register 18 (PSP) while CPU is running
ERROR: Can not read register 17 (MSP) while CPU is running
ERROR: Can not read register 13 (R13) while CPU is running
ERROR: Can not read register 12 (R12) while CPU is running
ERROR: Can not read register 11 (R11) while CPU is running
ERROR: Can not read register 10 (R10) while CPU is running
ERROR: Can not read register 9 (R9) while CPU is running
ERROR: Can not read register 8 (R8) while CPU is running
ERROR: Can not read register 7 (R7) while CPU is running
ERROR: Can not read register 6 (R6) while CPU is running
ERROR: Can not read register 5 (R5) while CPU is running
ERROR: Can not read register 4 (R4) while CPU is running
ERROR: Can not read register 3 (R3) while CPU is running
ERROR: Can not read register 2 (R2) while CPU is running
ERROR: Can not read register 1 (R1) while CPU is running
ERROR: Can not read register 0 (R0) while CPU is running
R0 = 00000000, R1 = 00000000, R2 = 00000000, R3 = 00000000
R4 = 00000000, R5 = 00000000, R6 = 00000000, R7 = 00000000
R8 = 00000000, R9 = 00000000, R10= 00000000, R11= 00000000
R12= 00000000, R13= 00000000, MSP= 00000000, PSP= 00000000
R14(LR) = 00000000, R15(PC) = 00000000
XPSR 00000000, APSR 00000000, EPSR 00000000, IPSR 00000000
CFBP 00000000, CONTROL 00, FAULTMASK 00, BASEPRI 00, PRIMASK 00
Reading all registers
ERROR: Can not read register 0 (R0) while CPU is running
ERROR: Can not read register 1 (R1) while CPU is running
ERROR: Can not read register 2 (R2) while CPU is running
ERROR: Can not read register 3 (R3) while CPU is running
ERROR: Can not read register 4 (R4) while CPU is running
ERROR: Can not read register 5 (R5) while CPU is running
ERROR: Can not read register 6 (R6) while CPU is running
ERROR: Can not read register 7 (R7) while CPU is running
ERROR: Can not read register 8 (R8) while CPU is running
ERROR: Can not read register 9 (R9) while CPU is running
ERROR: Can not read register 10 (R10) while CPU is running
ERROR: Can not read register 11 (R11) while CPU is running
ERROR: Can not read register 12 (R12) while CPU is running
ERROR: Can not read register 13 (R13) while CPU is running
ERROR: Can not read register 14 (R14) while CPU is running
ERROR: Can not read register 15 (R15) while CPU is running
ERROR: Can not read register 16 (XPSR) while CPU is running
ERROR: Can not read register 17 (MSP) while CPU is running
ERROR: Can not read register 18 (PSP) while CPU is running
ERROR: Can not read register 24 (PRIMASK) while CPU is running
ERROR: Can not read register 25 (BASEPRI) while CPU is running
ERROR: Can not read register 26 (FAULTMASK) while CPU is running
ERROR: Can not read register 27 (CONTROL) while CPU is running
Read 4 bytes @ address 0x00000000 (Data = 0xFFFFFFFF)
Setting breakpoint @ address 0x0000059C, Size = 2, BPHandle = 0x0001
Starting target CPU...
Debugger requested to halt target...
WARNING: CPU could not be halted
Reading all registers
WARNING: CPU could not be halted
ERROR: Can not read register 0 (R0) while CPU is running
ERROR: Can not read register 1 (R1) while CPU is running
ERROR: Can not read register 2 (R2) while CPU is running
ERROR: Can not read register 3 (R3) while CPU is running
ERROR: Can not read register 4 (R4) while CPU is running
ERROR: Can not read register 5 (R5) while CPU is running
ERROR: Can not read register 6 (R6) while CPU is running
ERROR: Can not read register 7 (R7) while CPU is running
ERROR: Can not read register 8 (R8) while CPU is running
ERROR: Can not read register 9 (R9) while CPU is running
ERROR: Can not read register 10 (R10) while CPU is running
ERROR: Can not read register 11 (R11) while CPU is running
ERROR: Can not read register 12 (R12) while CPU is running
ERROR: Can not read register 13 (R13) while CPU is running
ERROR: Can not read register 14 (R14) while CPU is running
ERROR: Can not read register 15 (R15) while CPU is running
ERROR: Can not read register 16 (XPSR) while CPU is running
ERROR: Can not read register 17 (MSP) while CPU is running
ERROR: Can not read register 18 (PSP) while CPU is running
ERROR: Can not read register 24 (PRIMASK) while CPU is running
ERROR: Can not read register 25 (BASEPRI) while CPU is running
ERROR: Can not read register 26 (FAULTMASK) while CPU is running
ERROR: Can not read register 27 (CONTROL) while CPU is running
Removing breakpoint @ address 0x0000059C, Size = 2
WARNING: Failed to read memory @ address 0x00000000
GDB closed TCP/IP connection
After some frustrating debugging, I finally got the chip to program. The problem seemed to be that the constant resetting or the reset pin by the WDT was causing noise on the rest of the SWD lines. I had no capacitors on any of the lines, but holding my finger on the pins while they programmed (a small capacitance was added by my contact) the chip programmed just fine and even debugs. The funny thing is I fully expected to have to place filtering caps as a permanent solution, but now the board programs just fine without me touching it. The WDT reset must have been causing the noise in the first place. It would probably be a good idea to still add those caps though...
Thanks for the help. The NMI pin also definitely needed to be pulled high too.
I added a pull up to the NMI pin, but there was no change. I'm beginning to think the chip is programming, but for some reason a reset is occurring internally at a regular interval when it starts running. What could be causing this?
-Watch Dog Timer? (I never turn it on, though)
-Something with the clock?
I'll try a few things, but I would like to know all things I should try.
Here is the code:
int main(void)
{
for (;;) // Forever loop
{
__asm("NOP");
}
}
Hi, Stephen,
You use the programming circuit of KV10 frdm board to program your KV10 processor on your own PCB, I think the solution is okay. I suggest you check the following items:
1)you should connect four pins to your own processor:
RST_TGTMCU(pin10 of SWD connector)
SWD_CLK_TGTMCU(pin4 of SWD connector)
SWD_DIO(pin2 of SWD connector)
GND
You have to cut the trace of the SWD_DIO/RST_TGTMCU to the KV10 on the FRDM board.
2)pls check if the power/gnd pins are connected correctly for your own PCB.
Hope it can help you
BR
XiangJun rong
Hi,
From my experience, the NMI pin should be high after Reset, so a pullup resistor is required for the NMI pin, otherwise, there is issue when you program the chip, because interrupt always happen when you program the chip.
I do not guarantee it solves your problem, anyway pls have a try.
BR
Xiangjun Rong