PDA

View Full Version : Shiftin question



ronjodu
- 11th November 2007, 17:13
I'm controlling 3 MAX 6957 LED Drivers daisy chained together, Dout to Din. Most of the 6957's ports are for LED's however I'm using the middle chip's port 24 thru 27 for switch inputs and monitoring the 6957's port change Interrupt. (Thanks Darryl for the Instant Interrupts.)

My question is how to receive the data sent from the 6957 when asked to send it. Here is the ISR.


Checkswitches:
disable
Low CS
ShiftOut IO, SCLK, MSBFIRST, [$D8, $00, $00, $00] 'send read command to chip 2
high CS
Low CS
ShiftOut IO, SCLK, MSBFIRST, [$D8, $00, $00, $00] 'push bits out SPI shoot(Datasheet page 10)
high CS
low CS
shiftin Datain, SCLK, LSBFIRST, [hold1, hold2, hold3, hold4] 'collect bits
'gosub setMbit
enable
@ INT_RETURN


The first shiftout loads the status bits into the shift register and the second shiftout pushes them out the Dout pin where I read them with the shiftin.
I only need the Byte in Hold4 but need to collect 3 bytes of garbage to get to it.
Is it ok to do it like this?


shiftin Datain, SCLK, LSBFIRST, [hold4, hold4, hold4, hold4]

I know it works this way but is it the right way? Or should I be doing something completely different?

Thanks for any replies. 16F876,PBP2.47,MCSP,MPASM,MCloader

mister_e
- 11th November 2007, 18:17
As far as i know, there's no SKIP feature in SHIFTIN (as in HSERIN), so i think your method is the way to go.

ronjodu
- 11th November 2007, 19:09
Thanks for the quick reply Steve.
It does work fine just looks weird.