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

P89LPC932 Auto Buad Detect

My project uses a P89LPC932 @ 11.0592 MHz
and CCLK equal to Fosc (11.0592MHz).

UART uses BGRG1:BGRG0 as Baud Rate Generator.

Buad = CCLK/((BRGR1,BRGR0)+16)

I want to mensurate width of pulse by ICA of CCU. A series pulses comes from a 'U' (55 HEX).

When Down edge of Start Bit comes, ICA capture first value T1.

When Up edge of First Data Bit comes, ICA capture second value T2.

So we have got a Count , Count = T2 - T1.

My question :

How can we set BGRG1:BGRG0 from Count ?

e.g. BGRG1:BGRG0 = Count * x +/- y ?

Parents
  • David:
    What I have done in a similar situation to yours, albeit on a different processor, I first worked out getting my microcontroller software fully working at hard set baud rates. Then I wrote down the baud rate timer values for three or four known baud rates.

    Next I perfected the capture process and got that code working so that it properly captured the time span between two known edges. (You have proposed the U character). I happened to use the <SPACE> character becasue it is easier to whack on the keyboard.

    I then ran the capture process for the same 3 or 4 baud rates mentioned above and wrote down the corresponding T1-T2 capture period. It is a good idea to run this several times to make sure your capture process is repeatable. Use the PC to generate the outputs that you sample for the capture test.

    You should find there to be a linear relationship between the fixed baud rate generator values that you wrote down at first and the corresponding capture period values you wrote down secondly. Using the 3 or 4 data points you can first compute the slope and intercept for this linear equation and then check the relationship with the remaining points. I found a spreadsheet handy for helping with the charting and trial computations.

    Once the equation between the capture values and the baud rate generator value is determined you need to render that in code on your target processor.

    On some occasions I have elected not to derive an equation and instead made a table of "system acceptable baud rates" such as 1200, 2400, 4800, 9600, 19200, and then in each row of the table place a min and max range for the capture period that would correspond to that baud rate. Then also in each table row there would be the nominally correct baud rate generator value for that rate. After the auto baud capture is completed subtract T1 and T2 and then scan the table min/max ranges to find which row in the table that corresponds to the captured measurement. When found then set the baud rate generator to that nominal baud rate.

    Hope this helps.
    Michael Karas

Reply
  • David:
    What I have done in a similar situation to yours, albeit on a different processor, I first worked out getting my microcontroller software fully working at hard set baud rates. Then I wrote down the baud rate timer values for three or four known baud rates.

    Next I perfected the capture process and got that code working so that it properly captured the time span between two known edges. (You have proposed the U character). I happened to use the <SPACE> character becasue it is easier to whack on the keyboard.

    I then ran the capture process for the same 3 or 4 baud rates mentioned above and wrote down the corresponding T1-T2 capture period. It is a good idea to run this several times to make sure your capture process is repeatable. Use the PC to generate the outputs that you sample for the capture test.

    You should find there to be a linear relationship between the fixed baud rate generator values that you wrote down at first and the corresponding capture period values you wrote down secondly. Using the 3 or 4 data points you can first compute the slope and intercept for this linear equation and then check the relationship with the remaining points. I found a spreadsheet handy for helping with the charting and trial computations.

    Once the equation between the capture values and the baud rate generator value is determined you need to render that in code on your target processor.

    On some occasions I have elected not to derive an equation and instead made a table of "system acceptable baud rates" such as 1200, 2400, 4800, 9600, 19200, and then in each row of the table place a min and max range for the capture period that would correspond to that baud rate. Then also in each table row there would be the nominally correct baud rate generator value for that rate. After the auto baud capture is completed subtract T1 and T2 and then scan the table min/max ranges to find which row in the table that corresponds to the captured measurement. When found then set the baud rate generator to that nominal baud rate.

    Hope this helps.
    Michael Karas

Children
No data