To LUGNET HomepageTo LUGNET News HomepageTo LUGNET Guide Homepage
 Help on Searching
 
Post new message to lugnet.robotics.handyboardOpen lugnet.robotics.handyboard in your NNTP NewsreaderTo LUGNET News Traffic PageSign In (Members)
 Robotics / Handy Board / 6519
6518  |  6520
Subject: 
Re: HB Serial line speed change
Newsgroups: 
lugnet.robotics.handyboard
Date: 
Sat, 24 Jul 1999 00:24:45 GMT
Original-From: 
George Musser Jr <gmusser@hotmail.ANTISPAMcom>
Reply-To: 
georgejr@NOSPAMmusser.com
Viewed: 
871 times
  
Here is the relevant function.  Note that it only works for baud rates up to
9600.

void set_baud(int rate)              /* For an 8 MHz clock */
{
if (rate >= 300)
poke(BAUD, 0xb0 | log2(9600/rate));
}

You'll need regdefines.c (for the address of BAUD) as well as the following
function:

int log2(int x)     /*  2**logx <= x < 2**(logx+1)  */
{
int logx;

if (x) {
logx = 15;
while (!(0x8000 & x)) {
x <<= 1;
logx--;
}
return logx;
}
else
return -1;
}

I personally like the generality of invoking log2(), but you can of course
use a series of if statements instead.

There is also a location in the pcode interpreter that you can POKE to
change the baud rate used by IC.  But until IC can adjust its rate, this
operation will break the connection.

George
--
George Musser
georgejr@musser.com
KF6LOJ



1 Message in This Thread:

Entire Thread on One Page:
Nested:  All | Brief | Compact | Dots
Linear:  All | Brief | Compact
    

Custom Search

©2005 LUGNET. All rights reserved. - hosted by steinbruch.info GbR