I found this on how to set the register.
// Set the baudrate to 115200
UART->UART_BRGR = 45; // 84000000 / 16 * x = BaudRate (write x into UART_BRGR)
But for a baudrate value of 115200 the value x i.e UART_BRGR comes out to be 45. It works but for a baud rate of 1000000 the value of UART_BRGR comes to 5.25. So I used 5 as the value of X i.e UART_BRGR and calculated the baudrate which is 1050000 but now when I set this baudrate I get garbage. What am I doing wrong here?