hcs08,
how to put new baud rate?
running 115200
int_sci1( 115200 );
run.....
now new baud rate ?
my code: init and close
void init_sci1( byte cfg,byte bh,byte bl ){
if( cfg ){
SCI1C1= 0x00; init
SCI1C3= 0x00;
SCI1S2= 0x00;
SCI1C2= 0x00;
SCI1BDH = bh; // 0x000D =115200
SCI1BDL = bl;
SCI1C3 |= 0x0F;
SCI1C2 |= ( SCI1C2_TE_MASK | SCI1C2_RE_MASK | SCI1C2_RIE_MASK);
} else {
close
SCI1C3 &= ~0x0F;
SCI1C2 &= ( (~ SCI1C2_RE_MASK) & (~SCI1C2_TE_MASK) & (~SCI1C2_TIE_MASK) & (~SCI1C2_RIE_MASK));
SCI1BDH = bh;
SCI1BDL = bl;
}
(void)SCI1D;
}
thanks,
Carlos,
//-------------------------------------------------------------------------
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
Thanks for the replies.
but I want to know how to put new baud rate?
being in 4800 to 115200 and change for example.
just updating the value SCI1BDH / L, not the end, does not change the baud rate!
the problem is that after starting at 115200 are not changing to new value!
problems is not put new value in sci runnig.
thanks,
Carlos,
Hello Carlos,
It should just be a matter of writing a new value to the baudrate registers.
The only limitation is that you must write high byte first low byte last, but you seem to be doing this.
Have you only tried 115200 and 4800 baud?
Going to 4800 baud involves a value in the high byte ($0138). What if you try for 9600 ($009D) just to see what happens.
Which exact S08 device are you using?
Hello Peg
the problems no is CALC value in BR.
problems is new value SCI no modifier.....
ex:
BR = 0x000D <----init sci run.....
new
BR = 0x009D <---------new value run...
results is = 0x000D <---- see
thanks,
Carlos,
Thanks for the replies. but I want to know how to put new baud rate? being in 4800 to 115200 and change for example. just updating the value SCI1BDH / L, not the end, does not change the baud rate! the problem is that after starting at 115200 are not changing to new value!