Hello Carlos,
You appear to have a 24MHz bus frequency. Therefore the new baud rate divisor value can be calculated by the expression 1500000 / baud. The value of 1500000 is derived from 24000000 / 16.
However, if you have an arbitrary baud rate value, and are using integer division, you will firstly need to provide "rounding" to obtain the closer divisor value. For example, for a baud rate of 153600, the calculated value would be 9, but a divisor of 10 gives a the closer result.
You would also need to be aware of the maximum allowable baud rate error, and provide a check that the calculated divisor value provides a sufficiently accurate result. Not all baud rates may be feasible, and the baud rate function may need to check the accuracy.
Assuming all required baud rates are a multiple of 100, it would be better to use the (baud / 100) value for the calculations. If you do this, the calculations will be more efficient because the value will remain within the bounds of an int, rather than require the use of a long integer.
When you write the divisor value to SCI1BD register, there is no need to write individually to the high and low bytes of the register. For the 115200 baud case, the following would be sufficient -
SCI1BD = 13;
Finally, keep in mind that with the use of the very high baud rates, such as 115200, the SCI receive ISR would potentially need to be serviced every 86 microseconds (or 2080 cycles). This means that the total execution period of the SCI receive ISR, plus any other ISR that may havet commenced just prior to the SCI interrupt, must be considerably less than the byte transmission period, to avoid loss of data.
Regards,
Mac