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
  • I see. But I must be detect a few baud, 1200, 1371, 1600, 1920, 2133, 2400, 2742, 3200, 3840, 4800, 6400, 7200, 9600, 10400, 19200, 38400, 57600, 115200 BPS. After I init my target MCU by Address Word, One of my target MCUs sends a 'U' for Baud Detect. So my project's P89LPC932 must be detect it's BAUD for Building Communication. My target MCU who sended 'U' will send 'U' always until P89LPC93 get correctly BAUD.

    After P89LPC93 has got correctly BAUD, it send 0xAA to my target MCU.

    So I have to measure Width of Pulse accurately for every Baud.

    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 ?

Reply
  • I see. But I must be detect a few baud, 1200, 1371, 1600, 1920, 2133, 2400, 2742, 3200, 3840, 4800, 6400, 7200, 9600, 10400, 19200, 38400, 57600, 115200 BPS. After I init my target MCU by Address Word, One of my target MCUs sends a 'U' for Baud Detect. So my project's P89LPC932 must be detect it's BAUD for Building Communication. My target MCU who sended 'U' will send 'U' always until P89LPC93 get correctly BAUD.

    After P89LPC93 has got correctly BAUD, it send 0xAA to my target MCU.

    So I have to measure Width of Pulse accurately for every Baud.

    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 ?

Children
  • I really can't determine why you are rejecting Michael's method. You seem to only want to derive BGRGn values by calculating them instead of simply looking them up in a table. Well, here's another method that doesn't calculate BGRG.

    Your functional description states: "My target MCU who sended 'U' will send 'U' always until P89LPC93 get correctly BAUD. After P89LPC93 has got correctly BAUD, it send 0xAA to my target MCU."

    Since your MCU will be receiving 'U' characters until it replies with 0xAA, then set the MCU UART to 1200bps and watch the receive pin for a start bit, then delay 10 bit times. Did the MCU receive a 'U'? If so, you're done; otherwise, step the UART up to the next baud rate and go back to waiting for the next 'U'. Loop through all your supported baud rates until you receive the 'U'.

    Personally, I'd still do it the way Michael recommended.

  • Your functional description states:
    "My target MCU who sended 'U' will send 'U'
    always until P89LPC93 get correctly BAUD.
    After P89LPC93 has got correctly BAUD, it
    send 0xAA to my target MCU."

    I am sorry for my description, it shoulds be following :

    There are a few MCU at bus, and every MCU
    has a individual Address Word, 01, 02,
    03 ... FF. My MCU is a tester, it inits MCU
    by Address Word @ 5 bps. After the
    corresponding MCU received it's Address
    Word, it send a series, e.g. 55 xx yy @ xxxx
    bps . 55 for Baud Detect. it repeats three
    times only (not always, I am sorry).
    
    After Received Address Word,Delay 30 ms,
    sends 55 xx yy ; Delay 30 ms, Wait Ack of my
    MCU , if not or Baud Error, then sends 55 xx
    yy again; then Delay 30 ms, Wait Ack of my
    MCU , if not or Baud Error, then sends 55 xx
    yy again, and Wait ....
    
    
    if No reply from My MCU, and Communication
    building Fail !
    
    

    So We must Detect Baud of MCU addressed immediately.

    if We can get Count = T2 - T1, and set BGRGx
    from Count, it is fast !

  • "So We must Detect Baud of MCU addressed immediately.

    if We can get Count = T2 - T1, and set BGRGx from Count, it is fast !"


    Personally, I'd still use 'Count' to look up BGRG values out of a table like Michael suggests in his last paragraph.

    If you want to calculate it, assuming you have the CCU configured with 1:1 prescale, wouldn't that be:

    BGRG1:BGRG0 = Count * 8 - 16?