How to set Uart2 ?

Please tell me how to use Uart2 to exchange data?

I Use C51 development and ST uPSD3234A chip.

Parents
  • Jonas,
    I just have a few questions regarding your previously posted code sample:
    1. Where is this "putchar()" function?
    2. Where do you enable your serial interrupt(i.e., perhaps ES2=1 alike statement)?
    3. Why do you need to enable TI2 in initialization? You should only enable TI2 when you have your serial transmit buffer ready. If you do the serial transmit from a function rather than from an interrupt, you can just simply write the first byte to the serial buffer and wait for TI2 to be set. More importantly, you need to clear TI2 before you can write your second byte into SBUF2. I suspect this could be your problem - you enable TI2 but never clear it, therefore no further UART transmit interrupt can occur.

    Good Luck!

Reply
  • Jonas,
    I just have a few questions regarding your previously posted code sample:
    1. Where is this "putchar()" function?
    2. Where do you enable your serial interrupt(i.e., perhaps ES2=1 alike statement)?
    3. Why do you need to enable TI2 in initialization? You should only enable TI2 when you have your serial transmit buffer ready. If you do the serial transmit from a function rather than from an interrupt, you can just simply write the first byte to the serial buffer and wait for TI2 to be set. More importantly, you need to clear TI2 before you can write your second byte into SBUF2. I suspect this could be your problem - you enable TI2 but never clear it, therefore no further UART transmit interrupt can occur.

    Good Luck!

Children
More questions in this forum