Hello everyone. I have a device which communicates through SPI, but I don't know how to do it or what I'm doing wrong. I'm using a PIC16F84, all the connections are direct, meaning from the PIC to the SPI there are no resistors.
The information on the SPI device is as follows:
Connections:
------------
VCC
Data
Clock
GND
SelectKey (When pulled low it will measure continuously)
Timeoue >2 ms
The timing diagram for SPI describes that between each bit there should be 500us for the clock cycle. And the information is MSB first.
I have written the following code to test it, with no luck.
DEFINE OSC 10
INCLUDE "modedefs.bas"
TX VAR PORTA.0
RX VAR PORTA.1
CS VAR PORTB.0 'Select low or high to activate This is for the SelectKey connection
CLK VAR PORTB.1 'Clock
DI VAR PORTB.2 'Data Input
DO VAR PORTB.2 'Data Output
BYTEIN VAR WORD
ATM CON $32 'CODE
TMSB CON $AC 'MSB
LLSB CON $F3 'LSB
START
GOSUB EREAD
GOTO START
EREAD
Low CS
Shiftout DI,CLK,MSBFIRST,[ATM,TMSB,LLSB]
Shiftin DO,CLK,MSBPRE,[BYTEIN]
High Cs
SEROUT2 TX,16468,[BYTEIN,10,13] '9600-8-N-1
PAUSE 3000
RETURN
END
------------------------------------------------------------------------------
Thanks in advance for your help.
Bookmarks