How does one go about decreasing the SPI clock speed?
Thanks,
Benjamin B. Roy
How does one go about decreasing the SPI clock speed?
Thanks,
Benjamin B. Roy
Hello. add this line to your code:
DEFINE SHIFT_PAUSEUS ms
ms is the time in milliseconds between clock pulses
What would be a good pause time? (Note that I am completely new to this)a
To obtain clock speed:
Freq [Hz] = 1/period[seconds]
Test it with 1 ms (about 1Khz).
If it doesnt work try with another SPI mode, remember MSB first.
This is my code:
<code>
DEFINE OSC 20
DEFINE HSER_RCSTA 90h
DEFINE HSER_TXSTA 24h
DEFINE HSER_SPBRG 21 ' 57600 Bauds
DEFINE HSER_CLOERR 1
DEFINE SHIFT_PAUSEUS 1000
INCLUDE "modedefs.bas"
Hserout ["ACTIVE",13]
RST var portd.0
SCLK var portd.1
CS var portd.2
DOUT var portd.3 'data from PIC to Gyro
DIN var portd.4 'data from gyro to PIC
temp var word'(2)
index var word
High SCLK
High CS
high RST
pause 1000
main:
low CS
Shiftout DOUT, SCLK, 1, [$3C,$00]
high cs
pause 100
low CS
SHIFTIN DIN, SCLK, 2, [temp\16]
high CS
pause 100
HSEROUT ["Temp: ",HEX4 temp,13]
pause 100
goto main
</code>
And the output I am getting out is (HEX):
ACTIVE
Temp: 0000
Temp: 0900
Temp: 0900
Temp: 0900
Temp: 0900
Thanks
Is it correct? Does it work?
Take a look on Table 41 STATUS Bit descriptions (Datasheet pp. 30):
Address 0x3D, 0x3C
Default 0x0000
Default is valid only until the first register write cycle.
Try reading X-Axis data or another register.
I tried reading the 0x04 register, and it just simply gives me 0x0000. I'm relatively sure my connections are right, but I could be wrong. Do I need any pull-ups? Are there any connections I need other than the SPI, reset, and power connections? Thanks
Last edited by InitialDriveGTR; - 24th September 2006 at 17:35.
Bookmarks