How to determine the frequency division parameters when only knowing the baud rate

        I got a new master controller to test its printing function, but I don't know what the baud rate is.

        So I added the following program to the main function:

  for(i=0;i<0xFF;i++)
        {
                TMR0_PR_P0 = i;
                UartPutc(0x55);
                UartPutc(0x55);
                UartPutc(0x55);
                UartPutc(0x55);
                UartPutc(i);
        }

        This program is used to monitor the configuration parameters of the register TMR_PR_P0. If a series of "55" appears in the printout, the parameters of the register will be printed out later.

        If there is no continuous "55" in the print, it is time to try other baud rates.

        For example, I should have printed at 115200 baud rate, but found that only at 57600 baud rate, the continuous "55" will appear. Obviously, the frequency has been reduced.

        Put a printout below:

        From this information, we can know that at 57600 baud rate, the appropriate register parameters are: CB~E2.

おすすめ

転載: blog.csdn.net/weixin_41904238/article/details/119764171