Hi ARM,
while developing code i am facing following issue. Processor - ARM cortex M3.Controller - lpc1778 we are developing code for UART3 ,CLKPWR_ConfigPPWR (CLKPWR_PCONP_PCUART3, ENABLE); LPC_UART3->LCR = 0x83; /* 8 bit, 1 stop bit, no parity, enable DLAB */ LPC_UART3->DLL = divisor & 0xFF; LPC_UART3->DLM = (divisor >> 8) & 0xFF; LPC_UART3->FDR = (mulval << 4) | divval; LPC_UART3->LCR &= ~0x80; /* Disable DLAB */ PINSEL_ConfigPin(0,0,2);//UART3 TX PINSEL_ConfigPin(0,1,2);//UART3 RX LPC_IOCON->P0_0 = (LPC_IOCON->P0_0 & ~0x7) | 0x02; LPC_IOCON->P0_1 = (LPC_IOCON->P0_1 & ~0x7) | 0x02; LPC_UART3->FCR = 1; LPC_UART3->TER = 0x80; if(interrupt) { LPC_UART3->FCR = 0x49; //Set FIFO Trigger to 4 characters and Enable DMA LPC_UART3->IER = 0x01; //Enable Interrupts /* preemption = 1, sub-priority = 1 */ NVIC_SetPriority(UART3_IRQn, ((0x01<<3)|0x01)); NVIC_EnableIRQ(UART3_IRQn);
and after this configuration i am calling a function i mention below
void BSP_UART3_Write_Char (U8 ch){ while ((LPC_UART3->LSR & 0x20) == 0); LPC_UART3->THR = ch;}
if i call this function , my code will hung up at hardfault_handler()please help me how to solve this issue, and why i am getting this issue
Hi Mohan,
As I understand from your explanation, you get a HardFault only when you call BSP_UART3_Write_Char() function.
If yes, then you can check the disassembly file on assembly instructions generated for your compiler option. Since this function is writing character, compiler shall create instructions to write byte access. You might need to check your CCR.UNALIGN_TRP bit settings and check whether your memory accesses are naturally aligned.
Thanks,
Uma
Mohan T said:if i call this function , my code will hung up at hardfault_handler
Where, exactly, does the Hard Fault occur?
Some links on debugging Hard Faults:
https://community.arm.com/developer/ip-products/system/f/embedded-forum/3257/debugging-a-cortex-m0-hard-fault