Hard Fault during UART2 initialization

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

Hard Fault during UART2 initialization

879 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by JGold on Tue Sep 07 08:42:28 MST 2010
I am running the RDB1768cmsis_UART example on my board, and the initialization of UART0 works fine, but when I change the code to initialize UART2, it causes a hard fault after this line:
[LEFT][SIZE=2][SIZE=2]C Code:[/SIZE]
[SIZE=2]LPC_UART2->LCR[/SIZE][SIZE=2] = 0x83; [/SIZE][SIZE=2][COLOR=#3f7f5f][SIZE=2][COLOR=#3f7f5f]// 8 bits, no Parity, 1 Stop bit, DLAB=1[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#3f7f5f]
[/COLOR][/SIZE]Debugger Assembly:
0x000003ac <UART0_Init+164>: strb r2, [r3, #12][/LEFT]

[LEFT][SIZE=3]I have no problems with UART0 and 1, but keep having Hard Faultys with UART2 and 3.[/SIZE][/LEFT]

[LEFT][SIZE=3]Thoughts?[/SIZE][/LEFT]


[/SIZE]
0 Kudos
Reply
3 Replies

864 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by JGold on Tue Sep 07 10:10:07 MST 2010
[SIZE=5]DOH!!![/SIZE]

I had code to turn it on, but but for some reason it failed to work.


Thanks.
0 Kudos
Reply

864 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by CodeRedSupport on Tue Sep 07 09:52:29 MST 2010

Quote: CodeRedSupport
Have you turned the power on for UART2/3 in the PCONP (Power Control for Peripherals) register. According to the LPC17 user manual, UART0/1 default to being powered on, but 2/3 don't.


And just in case, here is some (untested) code that should do this. Add this near the start of main(), and before you try to access the UARTs...

#define PCUART0_POWERON (1 << 3)
#define PCUART1_POWERON (1 << 4)
#define PCUART2_POWERON (1 << 24)
#define PCUART3_POWERON (1 << 25)

// Turn on power to UART2 and UART3
// (UART0 and UART1 on by default)
LPC_SC->PCONP |=  PCUART2_POWERON | PCUART3_POWERON;
Regards,
CodeRedSupport
0 Kudos
Reply

864 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by CodeRedSupport on Tue Sep 07 09:20:38 MST 2010
Have you turned the power on for UART2/3 in the PCONP (Power Control for Peripherals) register. According to the LPC17 user manual, UART0/1 default to being powered on, but 2/3 don't.

Regards,
CodeRedSupport.
0 Kudos
Reply