This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

I dont send any char to UART at LPC2378

Hi, firstly i am sorry my bad engilsh.

I have LPC2378. I write my code. I dont understand where is my problem..Help me please.

Xtal=16Mhz
Baudrate=9600

I have DOcklight program. I want to see what I am writing in this program at Docklight ASCII screen.

my UART input/output P0.2 and P0.3

and last question is;
#define TEMT (1<<6)
#define LINE_FEED 0xA
#define CARRIAGE_RET 0xD

what do these mean?

****************************

#include <stdio.h>
#include <LPC23xx.H>

void Initialize(void);

#define TEMT (1<<6)
#define LINE_FEED 0xA
#define CARRIAGE_RET 0xD

int main()
{ int i;
char c[]="Digital Tanima Sistemleri";

Initialize();

while(1)
{ i=0;

while(c[i])
{ U0THR=c[i];
i++;
} U0THR=LINE_FEED;
U0THR=CARRIAGE_RET;

/* Wait till U0THR and U0TSR are both empty */
while(!(U0LSR & TEMT)){} //??
} }

void Initialize()
{ PINSEL0=0x50;
U0FCR=0x7;
U0LCR=0x83;
U0DLL=0x00000067;
U0DLM=0x0;
U0LCR=0x3;
}

Parents
  • #include <stdio.h>
    #include <LPC23xx.H>
    
    void Initialize(void);
    
    #define TEMT (1<<6)
    #define LINE_FEED 0xA
    #define CARRIAGE_RET 0xD
    
    int main()
    { int i;
    char c[]="Digital Tanima Sistemleri";
    
    Initialize();
    
    while(1)
    { i=0;
    
    while(c[i])
    { U0THR=c[i];
    i++;
    } U0THR=LINE_FEED;
    U0THR=CARRIAGE_RET;
    
    /* Wait till U0THR and U0TSR are both empty */
    while(!(U0LSR & TEMT)){} //??
    } }
    
    void Initialize()
    { PINSEL0=0x50;
    U0FCR=0x7;
    U0LCR=0x83;
    U0DLL=0x00000067;
    U0DLM=0x0;
    U0LCR=0x3;
    }
    <pre/>
    
    
    

Reply
  • #include <stdio.h>
    #include <LPC23xx.H>
    
    void Initialize(void);
    
    #define TEMT (1<<6)
    #define LINE_FEED 0xA
    #define CARRIAGE_RET 0xD
    
    int main()
    { int i;
    char c[]="Digital Tanima Sistemleri";
    
    Initialize();
    
    while(1)
    { i=0;
    
    while(c[i])
    { U0THR=c[i];
    i++;
    } U0THR=LINE_FEED;
    U0THR=CARRIAGE_RET;
    
    /* Wait till U0THR and U0TSR are both empty */
    while(!(U0LSR & TEMT)){} //??
    } }
    
    void Initialize()
    { PINSEL0=0x50;
    U0FCR=0x7;
    U0LCR=0x83;
    U0DLL=0x00000067;
    U0DLM=0x0;
    U0LCR=0x3;
    }
    <pre/>
    
    
    

Children
  • When you noticed you forgot the proper tags for posting your source code - don't you think you should have gotten all the way back to your editor and copied the code again?

    The code posted in your first post have already lost the formatting. So as you can clearly see, the code in your second post is also without formatting. You can also see a <pre/> tag at the end of your post. Was it really <pre/> that the instruction said you should end a code block with?

    Line feed and carriage return are two characters representing end of line conditions. Moving to the next line, and moving back to the start of the line like an old type writer.

    It seems you have copied some code from someplace and trying to use it without understanding it. It is way better if you also retrieve the user manual for the processor, and look at the very good documentation of the UART. Then it will suddenly be obvious what each individual line is actually doing.

    Next thing - it isn't enough to know baudrate and crystal frequency to know if the baudrate is correctly initialized. The processor has a PLL that may - or may not - be used. And it has a register with divisors for the peripherial clocks.

    The debugger is good for helping with this. And of course the user manual for the processor. And an oscilloscope is an excellent tool for checking what baudrate you have in relation to the baudrate you want to have.

  • I am using debugger. I can see correct chars at UART1. But I can not see any chars at Docklight.
    I dont understand where is my fault. I read all documantation. But i dont solve the problem. I see only some characters ASCII screen at Docklight.

    I want to see that what i am wrote.

  • Where do your debugger see if you have the correct baudrate on the actual cable?

    Your code is not fun to read since you posted it without proper indentation.

    But an interesting thing is - how many characters can you give the UART without checking if there are room for more? What does the user manual for the processor say? A hint - have you read the descriptions about the U0LSR register in the processor user manual?