PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
Re: i2c for 16f877 with cmps03 digital compass |
Posted: Tue Mar 11, 2003 2:11 pm |
|
|
:=hey cud ne help me...m new to pcw....hav been trying to get the deventec cmps03 digital compass to work for over a week. it uses i2c communication, i hav been trying to figure out how the built-in functions works..but still cant get it running...
:=m using a 16f877 pic with 4MHz crystal...i need to get an accuracy of at least 1 degree
:=
---------------------------------------------------
This page has source code for the cmps03. It's written in
Hi-Tech C.
<a href="http://www.robot-electronics.co.uk/shop/Examples.htm" TARGET="_blank">http://www.robot-electronics.co.uk/shop/Examples.htm</a>
Here's the code:
<a href="http://www.robot-electronics.co.uk/files/Example.c" TARGET="_blank">http://www.robot-electronics.co.uk/files/Example.c</a>
To convert this code to CCS, you need to do these things:
<PRE>
1. Use #byte and #bit statements to define each of the PIC
registers and register bits that are used by the program.
<BR>
Here's a link that has a lot of those definitions already
done for you:
<a href="http://www.pic-c.com/forum/general/posts/8364.html" TARGET="_blank">http://www.pic-c.com/forum/general/posts/8364.html</a>
<BR>
2. Everywhere that the Hi-Tech code uses an "int", change it
to a "long" (or "int16" -- same thing as a "long" in CCS).
<BR>
3. Add some printf() statements to their main() code, so
you can display the results of their demo program.
<BR>
4. Get rid of the "__CONFIG(0x3f72)" statement. CCS uses
the #fuses directive for this.
</PRE>
___________________________
This message was ported from CCS's old forum
Original Post ID: 12536 |
|