Wire library and Serial baud rate

Hey guys

Components used-
Arduino Fio
HMC5883 sensor
xBee Pro S1

Got a bit of a weird issue. The project that I am coding requires a HMC5883 Magnometer, as well a standard serial connection to send data two and from wireless devices. In my case I'm using the xBee Pros.

I'm using the Wire library, and this code to initialise the sensor.

Wire.beginTransmission(0x1E); //open communication with HMC5883
Wire.send(0x02); //select mode register
Wire.send(0x00); //continuous measurement mode
Wire.endTransmission();

Everything is working perfectly, except for when I set the Serial baud rate to anything greater than 19200. If I do a serial print nothing or blankness comes through. I did change the setting in the monitor. If it's 19200 or below, it's perfect.

Now in this project, remote programming of the Arduino is needed, and that only works at 57600, because I am using the Fio.

So the choices I have are to either figure out why it won't work at 57600, or change the boot loader to program at 19200. I'd prefer to get the code working at 57600 though.

Any ideas?

Have you tried the sensor with another board ?
Or without the XBEE?

Hey

Yeah I did.

But, I just found the problem. It was a software problem.

I wrote a Serial comms library which accepts an int to set the Serial baud rate, and the Serial class's begin() function accepts a long. So for some reason there are some casting issues when casting from int to long. The value I was passing was getting changed to something else.