lpcware

Issues with HardFault_Handler in uart0

Discussion created by lpcware Employee on Jun 15, 2016
Latest reply on Jun 15, 2016 by lpcware
Content originally posted in LPCWare by hmd on Mon Oct 31 12:53:50 MST 2011
Hi all,
I made an uart driver, workig fine as an standalone project on an lpcxpresso 1769.
When i include the uart files with a project using several other peripherals (spi, timers,...) the project compiles fine.
When i load the programme, it doesnt work. start debbuging and it fails when ever it goes to uart initialisation,  specially when i select the pin function (before or after setting the uart peripheral!).
initialisation function:

void InitUart0 (void){
    //Power Control for Peripherals register: PCONP
    PCONP |= 1 << 3;                            // UART0 power/clock control bit.

    //activation du peripherique: PCLKSEL0      
    PCLKSEL0 |= (1 << 6); // PCLK_peripheral = CCLK

    //configuration des registres de l'uart
    U0LCR |= 1 << 7;                            // DLAB = 1
    U0LCR |= ( 1 << 0 | 1 << 1 );          // 8-bit character length

    //UART0 Baud Rate  : 19200

    U0DLL = 13;              
    U0DLM = 0;               

    // utilisation de la FIFO
    U0FCR |= (1 << 1 | 1 << 2);              // Clear FIFOs Tx/Rx  > self clear bit
    U0FCR |= 1 << 0;                             // enable FIFOs

    //enabling the interrupt
//    U0IER = 3;                // enable RBR(Receive Data Available) and THRE

    //Selection mode uart en sortie: pins P0.2 et P0.3
[B]    PinSelReg->PinSel0.Bitfield.P0_2 = 1;         // selected TXD0
    PinSelReg->PinSel0.Bitfield.P0_3 = 1;        // selected RXD0
[/B]
    //fin de configuration des registres de l'uart                         
    U0LCR = 3;                      // DLAB = 0
}
 
When ever i reach the bold lines the system goes to HardFault_Handler!!!
I made another project just spi and uart: same result. My uart project works fine.
For info: uart initialisation start first after the main or after other peripheral init is the same result... I spend all the afternoon looking around :confused:
I'm open to all suggestion.

thanks for your help.

Outcomes