Page 1 of 1

Baud rate out with HiTec Compiler

Posted: Thu Nov 10, 2011 5:00 pm
by medelec35
I have been playing with Hitec and bit banging RS232. With osc at 8MHz
The baud rates are way out.
e.g in rs232.c
for

Code: Select all

#define %m_SW_BAUD   %r - 20		//Under 10MHz
Baud = 497
For

Code: Select all

#define %m_SW_BAUD   %r - 255			//Under 10MHz
Baud = 1219

Since 255 is maximum variable can be, what would I need to adjust to get baud at a higher rate please?

Martin

Re: Baud rate out with HiTec Compiler

Posted: Thu Nov 10, 2011 5:36 pm
by medelec35
I’m guessing I am looking to change %r which currently set to 416?
Unfortunately I can't determine where the 416 is assigned. :(

Re: Baud rate out with HiTec Compiler

Posted: Thu Nov 10, 2011 6:32 pm
by medelec35
I’m assuming %r is calculated from required baud rate.
To give an idea on value of %r. I have got the baud rate of 2400 spot on by changing #define line to

Code: Select all

#define %m_SW_BAUD  79

This would imply HiTec bitbang RS232 is miles off from BoostC.
Therefore I would guess there would have to a separate defines for Boostc and HiTec .


Martin

Re: Baud rate out with HiTec Compiler

Posted: Fri Nov 11, 2011 11:44 am
by Benj
Hi Martin,

I will make a note to have a good look into this for hitech and boostc for the v5 CAL code as it allows any component that uses a UART to tap into the hardware/software UART functionality. Hopefully we can get something more reliable across the board.

Re: Baud rate out with HiTec Compiler

Posted: Tue Nov 15, 2011 4:49 pm
by medelec35
Thanks for reply Ben
I have done some further tests on just using boostC.
I have used two frequencies and two different baud rates
Here are results I had to adjust RS232 component to, in order for RS232 baud rates to be spot on.

Code: Select all

Freq      Baud         Value
4MHz	  2400          %r  - 80	Therefore if default  is 	%r  - 58, then %r should be 434 etc
4MHz	  4800          %r  - 54
8MHz	  2400          %r  - 40								
8MHz	  4800          %r  - 27
Would you mind letting me know a way I can set it up so %r can be reclulated for the different baud rates and different frequencies please and not just different baud rates.

Thanks
Martin