I would point you to
this page that I found while doing a
simple google search. While they use a pic 18f252, from what I can figure out, it should work for your pic 16f877a as well. Includes wiring diagrams, code sample, and basic explanation of the compass module.
To figure out which pins correspond to which data lines on your microcontroller, I would point you to the
Microchip website, specifically the
data sheet for
your particular uP. Make sure you look at the correct pin diagram, as that datasheet is for the whole family of PICs.
I've done next to nothing with PIC Basic, but I did notice that the code sample uses some of the Pro extensions to the langauge. Since it looks like you're not using the Pro version, you may be missing some of the commands. The key commands are SHIFTIN and SHIFTOUT. In case your version of PIC Basic doesn't include these, there appear to be "home made" versions of the commands on
this webpage.
Let us know if you run into any problems.
Good luck,
--Ryan
__________________
FRC 2046, 2007-2008, Student member
FRC 1708, 2009-2012, College mentor; 2013-2014, Mentor
FRC 766, 2015-, Mentor