PDA

View Full Version : Shiftin with external Clock howto ?



RFsolution
- 26th February 2011, 21:04
Hi

I have a hardware situation where I need to read a 12bit serial output
clocked by his own clock

If i'm right all Shiftin commands generates an own clock signal
is there a way to use an external clock with some sort of shiftin

When the chipselect pin goes low, the clock is present and starts sending the 12bits
once finished Chipselect goes high etc...

Any help welcome

HenrikOlsson
- 26th February 2011, 21:28
As far as I know there is no PBP command to do it. You could, depending on the speed of your external device clock, roll your own or perhaps you could use a PIC with a SSP module capable of operating in slave mode.

Since, if I understad correctly, YOU initiate the read by pulling the CS\ low (ie you know exactly when the data is starting to come in) it should be quite possible to roll your own routine if the speed is fairly low. It's nothing I've done personally though but off the top of my head something like:

InputData Var WORD
InputPin VAR PortB.0
ClockInput VAR PortB.1
CSOutput VAR PortB.2
i var BYTE

InputData = 0 ' Initialize
CSOutput = 0 ' Pull CS line low to initiate transfer

For i = 1 to 12 ' Get 12 bits
While ClockInput = 0 ' Wait for clock going high
Wend

InputData = InputData << 1 + InputPin

While ClockInput = 1 ' Wait for clock going low
Wend

Next ' Do next bit until we have 12

CSOutput = 1

/Henrik.

mackrackit
- 27th February 2011, 01:45
What device are you working with?

RFsolution
- 27th February 2011, 09:40
Well the device is a 16F877 which talks to a DAC7611, i have no access to the 16F877 software and would like to use the data (value) send to the DAC in another circuit
So i want to read what the 16F877 is sending to the dac by a small MCU