Dear friends,
Up to this point I have been developing applications with C. Now I need to move to c++ to take advantage of its object oriented design. I have transferred my C code for UAART1 of LPC1788 to C++, but I am having some problems with it. The DLL value is always set to 0xFF regardless of the values I assign to it in my code. Here is the code I have written:
void Init_UART(void) { // Initialize UART communication // Specifications: Data: 8 bits, Stop bits: 1, Parity: NO, Baudrate = 9600 // In PCONP UART1 is enabled by default // UAART0_CLK = CPU_CLK/4 = 25MHz (default) LPC_IOCON->P0_15 = 0x01; // P0.15 as TXD1 LPC_IOCON->P0_16 = 0x01; // P0.16 as RXD1 LPC_UART1->LCR = 1<<7; // Enable access to Divisor Latch Registers (BLAD bit = 1) LPC_UART1->DLL = 113; // ******************************************** LPC_UART1->DLM = 2; LPC_UART1->FDR = 0x41; // DIVADDVAL = 1; MULVAL = 4 // The baudrate is calculated as follows: BR = CLK_IN/[16*(256*DLM+DLL)*(1+DIVADDVAL/MULVAL)] = 9600 LPC_UART1->LCR = 0x03; // 8 data bits; 1 stop bit; no parity, DLAB bit = 0 LPC_UART1->FCR = 0x0F; // Enable FIFOs; RESET Rx and Tx FIFO for initial use; Enable DMA request for UART1; LPC_GPDMA->Config = 0x01; // Enable DMA controller in default little endian mode LPC_GPDMA->IntErrClr = 0xFF; // Clear all error interrupts for DMA controller LPC_GPDMA->IntTCClear = 0xFF; // Clear termination count interrupt for DMA controller }
I have read somewhere that I need to change some parts of LPC_177x-8x.s file in order to have C++ code work, but I have no idea. Please help me solve this problem.
best regards