Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Help me solve some LPC1768 UART programming problems

Status
Not open for further replies.

tejashs

Member level 1
Joined
Sep 4, 2011
Messages
38
Helped
4
Reputation
8
Reaction score
4
Trophy points
1,288
Activity points
1,513
hello guys,
i have started to learn ARM cortex m3 lpc1768 processor.
I am able to toggle bits, change CPU click frequency .
now i am stuck with UART programming, its not working
i tried to follow the UM and also the sample programs given

here is my code, can someone have a look at it

Code C - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
void Uart0Init(uint32_t BaudRate)
{
    uint32_t uartclk = 0,pclk = 0;
 
    LPC_PINCON->PINSEL0 &= ~0xF0; // configure P0.2 and P0.3 as RXD-0 and TXD-0 Pins
    LPC_PINCON->PINSEL0 |= 0x50;
    // read the clock division assigned to UART0 peripheral
    uartclk = (LPC_SC->PCLKSEL0 >> 6) & 0x03;
 
    switch (uartclk)
    {
    case 0x01:
        pclk = SystemCoreClock;
        break;
    case 0x02:
        pclk = SystemCoreClock / 2;
        break;
    case 0x03:
        pclk = SystemCoreClock / 8;
        break;
    case 0x00:
    default:
        pclk = SystemCoreClock / 4;
        break;
    }
    // Configure the Line Control Register
    // Also set the Divisor Latch Access Bit
    LPC_UART0->LCR = 0x83;
    pclk = pclk / (16 * BaudRate);
    LPC_UART0->DLM = pclk / 256;
    LPC_UART0->DLL = pclk % 256;
    LPC_UART0->FCR = 0x07;
    LPC_UART0->LCR = 0x03;
    LPC_UART0->IER = 0x00;
}





Code C - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
int main(void)
{
    uint32_t i=0;
    SystemInit();
    Uart0Init(9600);
    while(1)
    {
        LPC_UART0->THR = 'T';
        while (LPC_UART0->LSR & 0x20 );
        for(i=0;i<0xffff;i++);
    }
}



i am using coocox with GNU ARM compiler


edit: can some one take a quick look and gimme atleast some hints about where to look for the problem
i am using flash magic to download the hexfile so hardware might be file
 
Last edited:

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top