Shop OBEX P1 Docs P2 Docs Learn Events
Max6953 LED Matrix Controller — Parallax Forums

Max6953 LED Matrix Controller

Brian CarpenterBrian Carpenter Posts: 728
edited 2005-12-27 00:39 in General Discussion
I have a few of these chips and want to control them with the SX28.· I have been a little confused on the controlling of the chip, but i have found this.· It is written in C and for a pic.· Is it possible that someone would be interested in assisting me with this converting.· I have never used I2C on the SX, so i dont know what is neccisary.· I have looked through Gunther's book at the app notes.· Is all that stuff in the I2C master area required to be in the code in order to make it work?

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔


It's Only A Stupid Question If You Have Not Googled It First!!

Comments

  • Brian CarpenterBrian Carpenter Posts: 728
    edited 2005-12-23 12:17
    sorry here is the code that i found

    /******************************************************************************

    Driver routines for MAX6953 5x7 cathode-row LED display drivers.

    Written for the CCS PCM cross-compiler version 3.185

    Originally written by Stuart Hunter, Technical Director, ViziMatic Ltd.
    ******************************************************************************/


    #ifndef DISPLAY_SDA

    //The pin definitions are set for a PIC16F819 SSP module. If they are
    //redefined elsewhere before this file is included then your own definitions
    //will override these.
    #define DISPLAY_SDA· · ·· ·PIN_B1
    #define DISPLAY_SCL· · ·· ·PIN_B4
    #endif

    //Miscellaneous defines
    #define SLOW · ·· ·· ·· ·0· ·· ·//Use for setting blink rate· ·· ·
    #define FAST · ·· ·· ·· ·1
    #define PLANE0 · ·· ·· ·· ·0x20· ·//Use for setting data start address
    #define PLANE1 · ·· ·· ·· ·0x40
    #define BOTHPLANES · ·· ·· ·0x60
    #define WRITE_NOW · ·· ·· ·1· ·· ·//Used in operations affecting the CONFIG
    #define WRITE_LATER · ·· ·0· ·· ·//register.




    //Add FORCE_HW to the end of the line below if you want or need
    //to use a hardware I2C implementation (ie your PIC has the MSSP module).
    //Remove the line if you've already defined the I2C pins!!!
    #use i2c(master, sda=DISPLAY_SDA, scl=DISPLAY_SCL )· ·· ·//,FORCE_HW

    int config_byte;
    int device_address;


    // Initialise the I2C bus and config register
    void init_display()
    {
    · ·· ·output_float(DISPLAY_SCL);
    · ·· ·output_float(DISPLAY_SDA);
    · ·config_byte = 0;
    }

    void set_device_address( int addr )
    {
    · ·addr+= 0x50;· ·· ·· ·//MAX6953 addresses take the form 101xxxx
    · ·device_address = addr;· ·//where xxxx is the user-selected address 0-15.
    }

    // This function is mainly for internal use, but you can use it to
    // set the CONFIG register directly if you don't want to use the
    // individual functions provided for this purpose.
    void write_config_register( int config_byte )
    {
    · ·i2c_start();
    · ·i2c_write( (device_address<<1) & 0xFE );
    · ·i2c_write( 0x04 );
    · ·i2c_write( config_byte );
    · ·i2c_stop();
    }

    // This function sets the display interval for each display plane.
    // With a 4MHz clock, FAST is 0.5s and SLOW is 1.0s.
    void set_blink_speed( int speed, short wrt )
    {
    · ·if( speed == SLOW ) config_byte &= 0xFB;
    · ·else config_byte |= 0x04;
    · ·if( wrt ) write_config_register( config_byte );
    }

    // This function enables or disables plane switching ( blinking )
    void blink_enable( short state, short wrt )
    {
    · ·if( state ) config_byte |= 8;
    · ·else config_byte &= 0xF7;
    · ·if( wrt ) write_config_register( config_byte );
    }

    // This function is used for blink time synchronisation across multiple devices.
    // call it once for each device, in sequence. Nonpersistent.
    void blink_sync( void )
    {
    · ·write_config_register( config_byte |= 0x10 );
    }

    // Clear the plane data in the chip. Nonpersistent.
    void clear_digits( void )
    {
    · ·write_config_register( config_byte | 0x20 );
    }

    // Put the display into low power shutdown mode
    void shutdown( short state, short wrt )
    {
    · ·if( !state ) config_byte |= 0x01;
    · ·else config_byte &= 0xFE;
    · ·if( wrt ) write_config_register( config_byte );
    }

    // Put the display in test mode. Will illuminate all LEDs if state=TRUE.
    // Does not affect plane data - original display is restored when set FALSE.
    void display_test( short state )
    {
    · ·i2c_start();
    · ·i2c_write( (device_address<<1) & 0xFE );
    · ·i2c_write( 0x07 );
    · ·if (state )
    · ·{
    · ·· ·i2c_write( 1 );
    · ·}
    · ·else
    · ·{
    · ·· ·i2c_write( 0 );
    · ·}
    · ·i2c_stop();
    }

    // Set the display intensity from 0-15. This routine sets all digits to
    // the same value, if you want to set 'em individually then you need to
    // implement your own function - I don't need that ability!
    void set_intensity( int intens )
    {
    · ·int tempd;
    · ·tempd = intens<<4;· ·//set the most significant nybble
    · ·intens |= tempd;
    · ·i2c_start();
    · ·i2c_write( (device_address<<1) &0xFE );
    · ·i2c_write( 0x01 );· ·· ·//first intensity register
    · ·i2c_write( intens );
    · ·i2c_write( intens );· ·//register addr autoincrements, so write second reg.
    · ·i2c_stop();
    }

    // Sets the number of digits to be displayed ( 2 or 4 ). Included just for
    // the hell of it - I don't use this in my app.
    void set_scan_limit( short state )
    {
    · ·i2c_start();
    · ·i2c_write( (device_address<<1) &0xFE );
    · ·i2c_write( 0x03 );
    · ·if (state )
    · ·{
    · ·· ·i2c_write( 1 );
    · ·}
    · ·else
    · ·{
    · ·· ·i2c_write( 0 );
    · ·}
    · ·i2c_stop();
    }

    // Set the plane data for display. Normal characters should be written to
    // PLANE0. See the Maxim datasheet for an explanation of the data planing
    // system.
    void write_display_character( int start, int length, char* string )
    {
    · ·int n;

    · ·i2c_start();
    · ·i2c_write( (device_address<<1) &0xFE );
    · ·i2c_write( start );· ·· ·· ·· ·· ·· ·//start address of write operation
    · ·for( n=0; n<length; n++ )
    · ·{
    · ·· ·i2c_write( string[noparse][[/noparse]n] );· ·· ·· ·· ·//write noninverted string, address
    · ·}· ·· ·· ·· ·· ·· ·· ·· ·· ·· ·//will autoincrement.
    · ·i2c_stop();
    }

    // As above, but displays an inverted ( background lit, char off ) character.
    void write_inverted_display_character( int start, int length, char* string )
    {
    · ·int n;

    · ·i2c_start();
    · ·i2c_write( (device_address<<1) &0xFE );
    · ·i2c_write( start );· ·· ·· ·· ·· ·· ·//start address of write operation
    · ·for( n=0; n<length; n++ )
    · ·{
    · ·· ·i2c_write( string[noparse][[/noparse]n] |= 0x80 );· ·· ·//write inverted string, address
    · ·}· ·· ·· ·· ·· ·· ·· ·· ·· ·· ·//will autoincrement.
    · ·i2c_stop();
    }

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔


    It's Only A Stupid Question If You Have Not Googled It First!!
  • BeanBean Posts: 8,129
    edited 2005-12-23 12:34
    I don't have the time right now, but SX/B does have I2C commands. I would recommend you start there.
    Bean.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    "SX-Video·Module" Now available from Parallax for only $28.95

    http://www.parallax.com/detail.asp?product_id=30012

    "SX-Video OSD module" Now available from Parallax for only·$49.95
    http://www.parallax.com/detail.asp?product_id=30015

    Product web site: www.sxvm.com

    Forget about the past, plan for the future, and live for today.
    ·
  • Oliver H. BaileyOliver H. Bailey Posts: 107
    edited 2005-12-27 00:39
    It just so happens that CCS is working on the SX C compiler which we should see very soon. Many of the functions that exist in te PIC version will also be in the SX version. Your program would be an excellent sample program to test against providing you can wait a week or so. If not than by all means convert the program to SX/B. You will need to decide if the SX is going to be a master or slave I2C device. I2C is master controlled which means the master initiates all communications.
    PS: The C documentation is already posted in another thread so you can see if the functions in your source will be supported.

    Oliver Bailey
Sign In or Register to comment.