We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
Hi there, I am trying to config LPC930's uart port using the following codes: void uart_init ( void ) { // configure UART // clear SMOD0 PCON &= ~0x40; SCON = 0x50; // set or clear SMOD1 PCON &= 0x7f; PCON |= (0 << 8); SSTAT = 0x00;
// configure baud rate generator BRGCON = 0x00; BRGR0 = 0xF0; BRGR1 = 0x02; BRGCON = 0x03;
// TxD = push-pull, RxD = input P1M1 &= ~0x01; P1M2 |= 0x01; P1M1 |= 0x02; P1M2 &= ~0x02;
// initially not busy mtxbusy = 0;
// TI = 0; // set isr priority to 0 IP0 &= 0xEF; IP0H &= 0xEF; // enable uart interrupt ES = 1;
} // uart_init
and after calling this uart_init() i then tried to do a printf("hello world\n");
actually i did the printf() in a while(1) loop, hoping to catch something on the PC terminal. however, i dont get anything. then i tried to probe the TxD pin on LPC930, then i saw only one pulse going from high to low at the time the printf() should be executed. Can anyone help me with this issue?
I am using LPC930, internal xtal @ 7.373MHz, desired baudrate is 9600.
thanks
looks like the code is messed up. this is the cleaner one:
void uart_init ( void ) { // configure UART
// clear SMOD0
PCON &= ~0x40;
SCON = 0x50;
// set or clear SMOD1
PCON &= 0x7f;
PCON |= (0 << 8);
SSTAT = 0x00;
// configure baud rate generator
BRGCON = 0x00;
BRGR0 = 0xF0;
BRGR1 = 0x02;
BRGCON = 0x03;
// TxD = push-pull, RxD = input
P1M1 &= ~0x01;
P1M2 |= 0x01;
P1M1 |= 0x02;
P1M2 &= ~0x02;
// initially not busy
mtxbusy = 0;
// set isr priority to 0
IP0 &= 0xEF;
IP0H &= 0xEF;
// enable uart interrupt
ES = 1;
I think it's your eyes that must be messed up - the instructions look pretty clear to me:
www.danlhenry.com/.../keil_code.png
i now see why sometimes people think another individual is a jerk...this He Li guy messed up the code and then jumps out a guy saying this He Li's eyes are messed up...very friendly, indeed.
Andy is normally one of the most civil contributers to this forum, sir. Calling someones a jerk is not that friendly, either...!
Andy is the saint.
I'm the ruffian
(but I normally end up wanting, when Erik is at his best) :)
OK, so he did at least notice that the code was "messed up" - which is more than can be said for many!
But, the thing is: attention to detail is absolutely fundamental to programming - especially embedded programming.
I content that the instructions for posting source code are very clearly stated before your very eyes whenever you make a post to this forum - as highlighed in the picture:
If anyone can miss something stated that clearly, it must suggest a very high likelihood that they will also miss important details in the datasheets, etc - details which would be essential to getting stuff to work!
Have you tried the "Hello, world" sample provided by Keil?
Does that work?