KW01Z4128 access to UART0 registers (0x4006A000) results in hardfault

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

KW01Z4128 access to UART0 registers (0x4006A000) results in hardfault

Jump to solution
1,343 Views
johanleroy
Contributor I

When I try to access the UART0 (and other) registers i am ending up with a hardfault. I am in privileged mode as you can see in the next log from the debugger

Any idea what can be wrong here?

Halting target CPU...

...Target halted (PC = 0x000004E8)

Read 2 bytes @ address 0x000016F6 (Data = 0xF000)

Read 2 bytes @ address 0x000016F6 (Data = 0xF000)

Read 2 bytes @ address 0x000016F6 (Data = 0xF000)

R0 = 00000050, R1 = F000300C, R2 = 00000C00, R3 = 00001800

R4 = 1FFFF348, R5 = FFFFFFFF, R6 = 00000000, R7 = 1FFFF161

R8 = 2BFF2EBF, R9 = B745DFDD, R10= 1FFF3000, R11= 00000000

R12= A6F97FFE, R13= 20003000, MSP= 20003000, PSP= EB7FF6E4

R14(LR) = 1FFFF159, R15(PC) = 000004E8

XPSR 01000000, APSR 00000000, EPSR 01000000, IPSR 00000000

CFBP 00000000, CONTROL 00, FAULTMASK 00, BASEPRI 00, PRIMASK 00

Reading all registers

Read 4 bytes @ address 0x000004E8 (Data = 0xF001B672)

Setting breakpoint @ address 0x0000164A, Size = 2, BPHandle = 0x0001

Setting breakpoint @ address 0x000016EC, Size = 2, BPHandle = 0x0002

Setting breakpoint @ address 0x000016F6, Size = 2, BPHandle = 0x0000

WARNING: No more breakpoint resources left

Starting target CPU...

...Breakpoint reached @ address 0x0000164A

Reading all registers

Removing breakpoint @ address 0x0000164A, Size = 2

Removing breakpoint @ address 0x000016EC, Size = 2

Removing breakpoint @ address 0x000016F6, Size = 2

WARNING: Breakpoint @ address 0x000016F6 not found

Read 4 bytes @ address 0x0000164A (Data = 0x22004B22)

Reading 64 bytes @ address 0x20002FC0

Read 4 bytes @ address 0x00001714 (Data = 0x607B2300)

Read 4 bytes @ address 0x1FFFF000 (Data = 0x01312D00)

Reading 8 bytes @ address 0x1FFFF090

WARNING: Failed to read memory @ address 0x4006A000

Reading 384 bytes @ address 0x4006B000

WARNING: Failed to read memory @ address 0x4006B000

Tags (3)
0 Kudos
Reply
1 Solution
1,126 Views
DavidS
NXP Employee
NXP Employee

Hi Johan,

Usually hard fault occurs when you try to access a peripheral register without first enabling the clock to the peripheral module from within the SIM module SCGCx registers.  The SIM->SCGC4 bit 10 needs to be set to "1" to enable clocking to UART0.

Regards,

David

View solution in original post

3 Replies
1,126 Views
AngelC
Senior Contributor I

Hello Johan,

In addition, what software application are you exactly using? I would recommend you to use any of the code examples included in KW0x Board support package as reference. You could download it from “Software & Tools” tab in http://www.freescale.com/kw01.

Regards,

AngelC

0 Kudos
Reply
1,126 Views
johanleroy
Contributor I

Hi Angel,

Found tit yesterday evening and your answer was correct. Some part are a bit confusing regarding the clocking. There are 2 clock registers for the uart bit 10 of SIM_SGC4 and bits 26-27 of SIM_SOPT2 -> defaulted to 0 what means disable.

Apparently only the SIM_SGC4 must be enabled to be able to change the UART register settings even if the UART clock source in SIM_SOPT2 is disabled

I don't use any libraries, we are writing our own to be able to optimize for size and speed

Regards

Johan

0 Kudos
Reply
1,127 Views
DavidS
NXP Employee
NXP Employee

Hi Johan,

Usually hard fault occurs when you try to access a peripheral register without first enabling the clock to the peripheral module from within the SIM module SCGCx registers.  The SIM->SCGC4 bit 10 needs to be set to "1" to enable clocking to UART0.

Regards,

David