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

Problems with UART on a Philips P8xCL883

Hi, I'm a Dutch student busy with my in internship where I have to make an application with a Philips P8xCL883 microcontroller. I would like to use UART to send and receive strings from a PC, but I can not get this to work properly. I searched the web for some interrupt driver routines and found some very nice ones, but implementing these caused some weird problems.

I set the baudrate to 9600, but I can only receive chars when (on the PC) I send them with 28800 baud. If I search the datasheet of the P8xCL883 I did set the prescaler to the right value and I am using the right oscillator. The chars I then receive have a problem as well. For instance, if I send a "b" (binairy 01100010) I receive this as a 11000010. Hereby the 4th bit from the left should not be there and bits 1-3 should be shifted to the right 1 position. This happens with every char I receive. My mentor here can not help me with this and after a week of trying, I do not know where to look anymore.

I hope anyone can give me some clues so that I can get this communication to work. Thanks in advance, Terry.

The P8xCL883 runs on a 3.58 MHz crystal, which is different from a standard 8051. Using the prescaler I should be able to set the frequency for the baudrate, but this does not work for me. A datasheet is available from: http://www-us.semiconductors.philips.com/acrobat/datasheets/P8XCL883_CL884_2.pdf

Parents
  • After some calculations and some testing I found that setting the PRESC register to 34h seems to solve the receive problem. Reception works for 9600 baud.

    The formula:

    Baud Rate = ((2^SMOD) / 32) * Fpsc * (1 / ((2^PTWD) * (3^P3))

    is used, I take SMOD = 0, Fpsc = 1:5 Fosc = 715909, PTWD = 6 and P3 = 0. This gives a baud rate of 10240 baud, and perfect reception with 9600 baud sending from the PC.

    Setting Fpsc to 1:3 = 1193181.667, PTWD = 5 and P3 = 1 should give a baud rate of 9216, but does not work, reception of 9600 baud chars is not working properly.

    Very weird, but reception is working, I am happy as I can be today.

Reply
  • After some calculations and some testing I found that setting the PRESC register to 34h seems to solve the receive problem. Reception works for 9600 baud.

    The formula:

    Baud Rate = ((2^SMOD) / 32) * Fpsc * (1 / ((2^PTWD) * (3^P3))

    is used, I take SMOD = 0, Fpsc = 1:5 Fosc = 715909, PTWD = 6 and P3 = 0. This gives a baud rate of 10240 baud, and perfect reception with 9600 baud sending from the PC.

    Setting Fpsc to 1:3 = 1193181.667, PTWD = 5 and P3 = 1 should give a baud rate of 9216, but does not work, reception of 9600 baud chars is not working properly.

    Very weird, but reception is working, I am happy as I can be today.

Children
  • After reception works ok, I started to work on transmitting chars. It seems that I can not set the TI bit manual (or in software) to enter the interrupt routine. Not by setting the TI = 1; nor by S0CON |= 0x02;.

    Is there a way around this, so that I can enter the interrupt routine without setting the TI bit?

  • After reception works ok, I started to work on transmitting chars. It seems that I can not set the TI bit manual (or in software) to enter the interrupt routine. Not by setting the TI = 1; nor by S0CON |= 0x02; (S0CON = SM0, SM1, SM2, REN, TB8, RB8, TI, RI).

    Is there a way around this, so that I can enter the interrupt routine without setting the TI bit?