Help with a BS2SX and MAX6957 SPI
I have a BS2SX in a Board of Education. I thought I would play around with a MAX6957 (PDIP) LED Display Driver and I/O Expander. This has an SPI interface which I am trying to communicate with using SHIFTOUT / SHIFTIN. I have made the connections between the BS2SX and the MAX6957 as per the data sheet. I have nothing else connected to the MAX6957 at this time as I am just trying to write and read registers to verify I know how to talk to the device.
Below is a copy of a little test program I wrote to supposedly dump the values of the registers within the MAX6957. I have used a logic probe to at least verify the connections to the MAX6957 are correct, and I can see logic pulses and the control lines seem to be in the correct states at the appropriate times. However, the data returned from the MAX6957 appears to bear no resemblance to what the default power-up values of the registers should be according to the MAXIM datasheet.
Anyone have any experience with the MAX6957 in specific or can otherwise point to a "stupid moment" in the code below? I have been through the datasheet numerous times, rechecked my connections to the device, and what appears to be something that should be relatively simple and straight forward is turning out not to work.
Thanks in advance for any ideas or suggestions!
Greg York
Below is a copy of a little test program I wrote to supposedly dump the values of the registers within the MAX6957. I have used a logic probe to at least verify the connections to the MAX6957 are correct, and I can see logic pulses and the control lines seem to be in the correct states at the appropriate times. However, the data returned from the MAX6957 appears to bear no resemblance to what the default power-up values of the registers should be according to the MAXIM datasheet.
Anyone have any experience with the MAX6957 in specific or can otherwise point to a "stupid moment" in the code below? I have been through the datasheet numerous times, rechecked my connections to the device, and what appears to be something that should be relatively simple and straight forward is turning out not to work.
Thanks in advance for any ideas or suggestions!
Greg York
' Max6957.bs2
' This program uses the DEBUG console to display and set the
' various registers in the MAX6957.
' {$STAMP BS2sx}
' {$PBASIC 2.5}
SClk PIN 0 ' clock out
SDOut PIN 1 ' data out
SDIn PIN 2 ' data in
CS PIN 3 ' chip select
MaxReg VAR Word ' Address/Command register
RegCmd VAR MaxReg.HIGHBYTE ' Command byte of register
RegData VAR MaxReg.LOWBYTE ' Data byte of register
RegAddr VAR Byte ' Address of register to read or write
Col VAR Byte ' Debug screen column pointer
HIGH CS
LOW SClk
LOW SDOut
DEBUG CLS
DEBUG " Maxim 6957 Diagnostic Utility", CR
DEBUG CRSRXY, 2, 2
FOR RegAddr = 0 TO 15
DEBUG " ", HEX2 RegAddr
NEXT
DEBUG CR, REP "-"\50, CR
FOR RegAddr.HIGHNIB = 0 TO 5
DEBUG HEX1 RegAddr.HIGHNIB, HEX1 0
FOR RegAddr.LOWNIB = 0 TO 15
RegCmd = $80 | RegAddr
RegData = 0
LOW SCLK
LOW CS
SHIFTOUT SDOut, SClk, MSBFIRST, [noparse][[/noparse]MaxReg\16]
LOW SCLK
HIGH CS
LOW CS
LOW SDOut
SHIFTIN SDIn, SClk, MSBPOST, [noparse][[/noparse]MaxReg\16]
LOW SCLK
HIGH CS
DEBUG ".", HEX2 RegData
NEXT
DEBUG CR
NEXT
END
