at the moment I'm trying to connect a sensor via SPI to a PIC16C74.
After 2 days without luck I found my trouble is caused by reversed byte transfere.
PIC: MSB first, LSB last
Sensor: LSB first, MSB last
I must turn all bytes before writing to SSPBUF and after reading SSPBUF.
But this takes to many cycles for execution! (controller only 4MHz)
1. solution
RRL x,1
RRF y,1
RRL x,1
RRF y,1
RRL x,1
RRF y,1
RRL x,1
RRF y,1
RRL x,1
RRF y,1
RRL x,1
RRF y,1
RRL x,1
RRF y,1
RRL x,1
RRF y,1
2. solution
clrf y
btfss x,0
bsf y,7
btfss x,1
bsf y,6
btfss x,2
bsf y,5
btfss x,3
bsf y,4
btfss x,4
bsf y,3
btfss x,5
bsf y,2
btfss x,6
bsf y,1
btfss x,7
bsf y,0
Any idea to solve this problem with less cycles ????
No hidden config bit available to make reverse transmition ???
Thanks in advance.
Ralf
r...@fto.de (Ralf Stuber) wrote in message news:<63ad86bb.04081...@posting.google.com>...
> Hello,
>
> at the moment I'm trying to connect a sensor via SPI to a PIC16C74.
>
> After 2 days without luck I found my trouble is caused by reversed byte transfere.
>
> PIC: MSB first, LSB last
> Sensor: LSB first, MSB last
>
> I must turn all bytes before writing to SSPBUF and after reading SSPBUF.
I'm not familiar with that chip, but I suppose you could always do the
SPI in software instead of using the built-in hardware bits. Then you
can control bit order.
Alternately, a lookup table but that's *a lot* of memory and not speed
up that much.
This is only taking 17 cycles, or 4us. How much faster do you expect
to make it?