i2c non-eeprom examples?


Closed Thread
Results 1 to 15 of 15

Hybrid View

  1. #1
    Join Date
    Mar 2005
    Posts
    15


    Did you find this post helpful? Yes | No

    Default

    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.

  2. #2
    justDIY's Avatar
    justDIY Guest


    Did you find this post helpful? Yes | No

    Default

    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):

    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).
    so I would try:

    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!

  3. #3
    Join Date
    Mar 2005
    Posts
    15


    Did you find this post helpful? Yes | No

    Default MAX6953 <-> pic16f870: working!

    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

  4. #4
    Join Date
    Jan 2010
    Posts
    37


    Did you find this post helpful? Yes | No

    Default

    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

Similar Threads

  1. I2C Master/Slave 16F88/16F767 working code
    By DanPBP in forum Code Examples
    Replies: 2
    Last Post: - 23rd October 2012, 22:31
  2. Can't read sequential addresses in external EEPROM
    By tjkelly in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 18th February 2010, 14:46
  3. Problem with I2C EEPROM addressing
    By Atom058 in forum General
    Replies: 14
    Last Post: - 3rd November 2009, 03:17
  4. HARDWARE I2C SAMPLE CODE question
    By Michael Wakileh in forum Code Examples
    Replies: 2
    Last Post: - 16th June 2009, 21:07
  5. Pic16F628A and 24LC256 EEPROM I2C
    By Mike96 in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 1st January 2006, 03:13

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts