View previous topic :: View next topic |
Author |
Message |
microJuan
Joined: 08 Mar 2008 Posts: 6
|
fast clock SPI |
Posted: Sun Aug 24, 2008 4:36 pm |
|
|
Hi folks, I apologise if this topic has been covered already but I didn't have luck finding a related post and I am new to picc.
Is it possible to read a 16 bit sync serial signal that gets updated at 16kHz ? Can I use spi_read( )? If so, could someone please point me in the right direction with the code.
Many thanks
Juan |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Sun Aug 24, 2008 7:24 pm |
|
|
If you want help, tell us the manufacturer and part number of the SPI
device that provides the 16-bit data. Also post a link to the data sheet
for the device. |
|
|
microJuan
Joined: 08 Mar 2008 Posts: 6
|
|
Posted: Mon Aug 25, 2008 1:09 am |
|
|
Hi,
the device datasheet can be found in www.finger-kg.de/lieferprogramm/micrometer/tastende_laser/doku/files/SLS7000Manfi.pdf
Figure 220 on page 22 shows the data output format. I have used two max485's (in receiver mode) one for the data signal and the other for clock signal. The outputs of these max485 comes up nicely on a CRO. I can see the clock signal as well the data signal.
Any suggestions as to how I can read this signal would be of great help.
Many thanks
Juan |
|
|
Ttelmah Guest
|
|
Posted: Mon Aug 25, 2008 10:02 am |
|
|
Yes, you should be able to receive this with the SPI hardware.
The bit order is right for SPI.
You would need to run the PIC as slave, with CKP=0, and CKE=0.
I can't see any real problems, except possibly needing to implement a 'synchronise' routine. I'd suggest that on the PIC waking, or if the checksum fails, you disable the SPI hardware, and sit monitoring the clock line. You look for a gap in the clock, longer than the 1/16000th of a second between bits, and when this is seen, restart the SPI. This way, you will be synchronised to the clock from the device, and regain sync, if it gets lost.
Best Wishes |
|
|
|