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.
Code:
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?
Code:
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
Bookmarks