Thanks! The address looks better now, but it still doesn't work yet.
I'll keep trying and will let you know when it works. If someone else got a good idea, I would like to here it too!
Thanks! The address looks better now, but it still doesn't work yet.
I'll keep trying and will let you know when it works. If someone else got a good idea, I would like to here it too!
hmm all i can think of is make sure the various decalres and registers are setup properly for i2c writes
if your pic has an MSSP module, you could try HBUSOUT and HBUSIN
also, make sure your i2c bus is wired properly, sda and scl need to be pulled high.
you can try breaking your commands down to their basics, write the address byte and wait for an ack, write the command byte, wait for an ack, data byte, ack .... etc ... just to troubleshoot your communications.
Thanks for the reply. I've pulled up the ports and it look like it works now! It is possible to put the LED-driver into the test-mode and to set it back to normal operation.
The only problem is that I can't get a character on the display. To find te problem I've attached a serial cable to the PIC and added some debug commands.
The code I've used:
Include "modedefs.bas"
DEFINE OSC 20
'DEFINE I2C_HOLD 1
SCL VAR PORTB.4
SDA VAR PORTB.5
CommandByte VAR BYTE
SlaveAddress var BYTE
DataByte VAR BYTE
ReadData VAR BYTE
Character VAR BYTE
'Set Debug pin port
DEFINE DEBUG_REG PORTC
'Set Debug pin bit
DEFINE DEBUG_BIT 5
'Set Debug baud rate
DEFINE DEBUG_BAUD 2400
'Set Debug mode: 0 = true, 1 = inverted
DEFINE DEBUG_MODE 1
Init:
Debug "-->> Start <<--", 10 ,13
Debug "Test mode", 10 ,13
SlaveAddress = $A0 'Set the device address at the I2C-bus (datash. p. 10)
CommandByte = $07 'Set the Command Byte ($07 = displaytestmode. Datasheet page 11)
DataByte = $01 'Set the Data Byte
I2CWRITE SDA, SCL, SlaveAddress, CommandByte, [DataByte] 'Write the data to the I2C-device
I2CREAD SDA, SCL, SlaveAddress, [ReadData]
Debug "ReadData = ", dec ReadData ,10 ,13 ,10 ,13
pause 500
Debug "Normal mode", 10 ,13
SlaveAddress = $A0 'Set the device address at the I2C-bus (datash. p. 10)
CommandByte = $07 'Set the Command Byte ($07 = Normal mode. Datasheet page 11)
DataByte = $00 'Set the Data Byte
I2CWRITE SDA, SCL, SlaveAddress, CommandByte, [DataByte] 'Write the data to the I2C-device
I2CREAD SDA, SCL, SlaveAddress, [ReadData]
Debug "ReadData = ", dec ReadData ,10 ,13 ,10 ,13
pause 500
Debug "Set LED intensity 1", 10 ,13
SlaveAddress = $A0 'Set the device address at the I2C-bus (datash. p. 10)
CommandByte = $01 'Set the Command Byte ($01 = Intensity10. Datasheet page 11)
DataByte = $FF 'Intensity of all segments set to maximum (Page 20)
I2CWRITE SDA, SCL, SlaveAddress, CommandByte, [DataByte] 'Write the data to the I2C-device
I2CREAD SDA, SCL, SlaveAddress, [ReadData]
Debug "ReadData = ", dec ReadData ,10 ,13 ,10 ,13
pause 500
Debug "Set LED intensity 2", 10 ,13
SlaveAddress = $A0 'Set the device address at the I2C-bus (datash. p. 10)
CommandByte = $02 'Set the Command Byte ($02 = Intensity32. Datasheet page 11)
DataByte = $FF 'Intensity of all segments set to maximum (Page 20)
I2CWRITE SDA, SCL, SlaveAddress, CommandByte, [DataByte] 'Write the data to the I2C-device
I2CREAD SDA, SCL, SlaveAddress, [ReadData]
Debug "ReadData = ", dec ReadData ,10 ,13 ,10 ,13
pause 500
Debug "Set Scan-Limit", 10 ,13
SlaveAddress = $A0 'Set the device address at the I2C-bus (datash. p. 10)
CommandByte = $03 'Set the Command Byte ($01 = Intensity10. Datasheet page 11)
DataByte = $01 'Intensity of all segments set to maximum (Page 20)
I2CWRITE SDA, SCL, SlaveAddress, CommandByte, [DataByte] 'Write the data to the I2C-device
I2CREAD SDA, SCL, SlaveAddress, [ReadData]
Debug "ReadData = ", dec ReadData ,10 ,13 ,10 ,13
pause 500
Debug "Character 'I'D0,P0&P1", 10 ,13
SlaveAddress = $A0 'Set the device address at the I2C-bus (datash. p. 10)
CommandByte = $60 'Set the Command Byte ($60 = Digit 0 Plane P0 & P1. Datasheet page 11)
DataByte = $49 'Display Character 'I'
I2CWRITE SDA, SCL, SlaveAddress, CommandByte, [DataByte] 'Write the data to the I2C-device
I2CREAD SDA, SCL, SlaveAddress, [ReadData]
Debug "ReadData = ", dec ReadData ,10 ,13 ,10 ,13
Debug "-->> End <<--", 10 ,13 ,10 ,13 ,10 ,13
end
And this is the result at my serial port:
-->> Start <<--
Test mode
ReadData = 0
Normal mode
ReadData = 0
Set LED intensity 1
ReadData = 0
Set LED intensity 2
ReadData = 1
Set Scan-Limit
ReadData = 0
Character 'I'D0,P0&P1
ReadData = 0
-->> End <<--
While the chip is in test-mode, the LED's are all burning. After the testmode, no LED is burning.
well, i had my basics confused ... hbusin/out is a proton command, not an melabs command - appologies
anyway the data sheet talks about "read-after-write verification" (pgs 7-9):
so I would try:When performing read-after-write verification, reset the command byte's address because the stored byte address generally is autoincremented after the write (Table 4).
I2CWRITE SDA, SCL, SlaveAddress, CommandByte, [DataByte] ' write data to register
I2CREAD SDA, SCL, SlaveAddress, CommandByte, [ReadData] ' reset pointer and read register
depending how your program will end up, you can also use the auto-increment feature to write all the configuration with a single I2CWRITE command, just add more byte variables, after your DataByte
as far as no character showing up, not sure what to say there... from a cursory glance, I find no errors in what youve written compared to the datasheet. double, triple, quadruple check your wiring to the datahseet ... I experimented with maxim's 6956, a little simpler beast than what you have there, but it still took a lot of fiddling to make it work!
Yes, it's working.
What I was doing wrong was not setting the intensity registers, so the LED's won't light up. Here's the configuration code I'm using now:
SetConfig:
SlaveAddressWrite = $A0
CommandByte = $04 'Set the Command Byte ($04 = Configuration Datasheet page 11)
DataByte = $81 '10000001 Tabel 7 page 12
FOR i = 0 to nAddress
I2CWRITE SDA, SCL, SlaveAddressWrite, CommandByte, [DataByte] 'Write the data to the I2C-device
I2CREAD SDA, SCL, SlaveAddressWrite, CommandByte, [RcvDataByte]
SlaveAddressWrite = SlaveAddressWrite + $02
NEXT i
return
LEDintensity: 'Set intensity of all LEDs
SlaveAddressWrite = $A0
CommandByte = $01 'Set the Command Byte ($01 = Intensity10. Datasheet page 11)
DataByte = Intensity '$FF 'Intensity of all segments set to maximum (Page 20)
I2CWRITE SDA, SCL, SlaveAddressWrite, CommandByte, [DataByte] 'Write the data to the I2C-device
I2CREAD SDA, SCL, SlaveAddressWrite, CommandByte, [RcvDataByte]
for i = 0 to nAddress
I2CWRITE SDA, SCL, SlaveAddressWrite, CommandByte, [DataByte] 'Write the data to the I2C-device
I2CREAD SDA, SCL, SlaveAddressWrite, CommandByte, [RcvDataByte]
SlaveAddressWrite = SlaveAddressWrite + $02
NEXT i
SlaveAddressWrite = $A0
CommandByte = $02 'Set the Command Byte ($01 = Intensity10. Datasheet page 11)
DataByte = Intensity '$FF 'Intensity of all segments set to maximum (Page 20)
I2CWRITE SDA, SCL, SlaveAddressWrite, CommandByte, [DataByte] 'Write the data to the I2C-device
I2CREAD SDA, SCL, SlaveAddressWrite, CommandByte, [RcvDataByte]
for i = 0 to nAddress
I2CWRITE SDA, SCL, SlaveAddressWrite, CommandByte, [DataByte] 'Write the data to the I2C-device
I2CREAD SDA, SCL, SlaveAddressWrite, CommandByte, [RcvDataByte]
SlaveAddressWrite = SlaveAddressWrite + $02
NEXT i
return
Hi RubenR!
Can you post entire code you used to control MAX6953 driver?
I try to use what is posted here but I have many error.
Thank you very much
Bookmarks