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

uart on LPC930 not working

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

Parents
  • 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;

    } // uart_init

Reply
  • 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;

    } // uart_init

Children