I wonder if an extra clock transition is being detected before the first byte is sent. This causes the remaining bits to be shifted right. One cause is incorrect clock polarity. I'm not sure about true SPI, my experience was mostly with microwire and worse. Example would be: Clock idles high. Transmission begins, clock driven low, then MSB output on data then a pulse on clock then next bit and so on. If circuit triggered on the falling edge it would consistantly go off 1 bit early, inserting a false MSB, looking like a right shift. Oliver. ----- Original Message ----- From: Tobie Horswill To: Sent: Monday, September 18, 2000 9:21 PM Subject: [PIC] : SPI doing a right-shift ? > Hi, > > I've been trying to get a Vector 2X electronic compass to talk to a > 16F877 and have been experiencing some weird stuff. I've configured the > compass in master mode and the PIC in slave, the compass sends a new bearing > approximately 5 times/second. Each time the compass has finished calculating > the heading it momentarely drops the EOC pin to ground before sending it's > 16 bit (0-359 decimal) value, so I used the EOC pin connected to RB0/INT to > frame the transmissions. Everything works fine at this point, when EOC drops > low the PIC branches to the proper interrupt handler and updates a flag in > RAM to be later used by the SPI interrupt handler so it can distinguish > between the HI and LO bytes received and store them accordingly. > > For some reason, the PIC keeps right shifting the values sent by the > compass. For example if the compass sends 3590 (0000000101100111) the PIC > reads 1790 (0000000010110011) ... Could it be that the compass sends it's 16 > bits non stop (without pausing between each byte) while the PIC needs more > space to "breath" between each byte ? I guess I could run the PIC as master > and the compass as slave and have the PIC pause it's SCK between bytes if > that is the problem but I would prefer having the compass update itself > rather than have the PIC polling it all the time... > > Thanks, > > __________________________________ > Tobie Horswill (thorswilATvideotron.ca) > Ex Machina, QC. CA. > > -- > http://www.piclist.com hint: To leave the PICList > mailto:piclist-unsubscribe-request@mitvma.mit.edu > > > -- http://www.piclist.com hint: PICList Posts must start with ONE topic: "[PIC]:" PIC only "[EE]:" engineering "[OT]:" off topic "[AD]:" ad's