CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

ICM7228 8-digit, 7-segment, numeric LED display Driver

 
Post new topic   Reply to topic    CCS Forum Index -> Code Library
View previous topic :: View next topic  
Author Message
jitun



Joined: 25 Mar 2009
Posts: 5

View user's profile Send private message Yahoo Messenger

ICM7228 8-digit, 7-segment, numeric LED display Driver
PostPosted: Tue May 12, 2009 3:15 am     Reply with quote

I had used this code in one of my previous project.The code is for interfacing ICM7228 from Intersil(Actually I used this) but if will work fine for the same from Maxim. Thought it will be helpful to someone.


ICM7228.c

Code:

#define clk_delay 1

int1 global_mode;
int1 global_ram;
//used to strobe the write pin of ICM7228
//Used as helper function
void pulse_write()
{
      output_high(ICM_WRITE);
      delay_cycles(clk_delay);
      output_low(ICM_WRITE);
      output_high(ICM_WRITE);
}
//Takes an array of 8 datas and put them on the digits
//the dp decides the position of the decimal point
//1 -> decimal point on 1st digit
//8 -> decimal point on 8th digit
//mode decides which mode of decoding to use CODE B OR HEX
//0 -> CODE B Decode
//1 -> Hex Decode
//ram decides which RAM  bank to use.
//0 -> RAM bank B
//1 -> RAM bank A
   void display_digits(unsigned int8 arr[],unsigned int8 dp,int1 mode,int1 ram)
   {
      unsigned int8 i;
      int decimal;
      global_mode=mode;
      global_ram=ram;
      if(dp>0 && dp<9)
         decimal=dp-1;
      else
         decimal=-1;
      output_low(ICM_WRITE);
      output_high(ICM_MODE);
      if(mode)
      {
         if(ram)
            ICM_PORT(0xD8);
         else
            ICM_PORT(0xD0);
      }
      else
      {
         if(ram)
            ICM_PORT(0x98);
         else
            ICM_PORT(0x90);
      }

      pulse_write();
      output_low(ICM_MODE);
      //for(i=0;i<8;i++)
      //   arr[i]=data[i];
      for(i=0;i<8;i++)
      {
         if(decimal==i)
            ICM_PORT(arr[i]+0x00);
         else
            ICM_PORT(arr[i]+0x80);
         pulse_write();
      }
      output_high(ICM_MODE);

      if(mode)
      {
         if(ram)
            ICM_PORT(0x58);
         else
            ICM_PORT(0x50);
      }
      else
      {
         if(ram)
            ICM_PORT(0x18);
         else
            ICM_PORT(0x10);
      }

      pulse_write();

   }
//Takes an array of 8 datas and put them on the digits
//this is for the no decode mode operation
   void display_digits_nd(unsigned int8 arr[])
   {
      unsigned int8 i;
      output_low(ICM_WRITE);
      output_high(ICM_MODE);

      ICM_PORT(0xB0);
      pulse_write();

      output_low(ICM_MODE);

      for(i=0;i<8;i++)
      {
         ICM_PORT(arr[i]^0x80);
         pulse_write();
      }
      output_high(ICM_MODE);

      ICM_PORT(0x30);
      pulse_write();

   }
//it displays a data at the address given
//1 -> 1st digit
//8 -> 8th digit
//and dis_data is the data that is to be displayed there
//the dp decides whether the decimal point is to be added or not
   void update_single_digit(unsigned int8 addr, unsigned int8 dis_data,int1 dp)
   {
      output_low(ICM_WRITE);
      output_high(ICM_MODE);
      if(global_mode)
      {
         if(global_ram)
            ICM_PORT(0x58+(addr-1));
         else
            ICM_PORT(0x50+(addr-1));
      }
      else
      {
         if(global_ram)
            ICM_PORT(0x18+(addr-1));
         else
            ICM_PORT(0x10+(addr-1));
      }

      pulse_write();
      output_low(ICM_MODE);

      if(dp)
          ICM_PORT(dis_data+0x00);
      else
          ICM_PORT(dis_data+0x80);

      pulse_write();
   }
//it displays a data at the address given in no decode mode
//1 -> 1st digit
//8 -> 8th digit
//and dis_data is the data that is to be displayed there
//the dp decides whether the decimal point is to be added or not
   void update_single_digit_nd(unsigned int8 addr, unsigned int8 data)
   {
      output_low(ICM_WRITE);
      output_high(ICM_MODE);
      ICM_PORT(0x30+(addr-1));
      pulse_write();
      output_low(ICM_MODE);

      ICM_PORT(data+0x80);
      pulse_write();
   }
//it toggles the ram bank from A to B and vice versa.
//it is usefull when u need to show two values continously
//without updating the display ram
void toggle_ram()
{
    output_high(ICM_MODE);
    if(global_mode)
    {
      if(global_ram)
         ICM_PORT(0x50);
      else
         ICM_PORT(0x88);
    }
    else
    {
      if(global_ram)
         ICM_PORT(0x10);
      else
         ICM_PORT(0x18);
    }
    pulse_write();
    output_low(ICM_MODE);
    global_ram=~global_ram;
}


Usage exmaple

main.C

Code:

#include <18F4550.h>
#device adc=8

#FUSES NOWDT                    //No Watch Dog Timer
#FUSES WDT128                   //Watch Dog Timer uses 1:128 Postscale
#FUSES HSPLL                    //High Speed Crystal/Resonator with PLL enabled
#FUSES NOPROTECT                //Code not protected from reading
#FUSES BROWNOUT                 //Reset when brownout detected
#FUSES BORV20                   //Brownout reset at 2.0V
#FUSES NOPUT                    //No Power Up Timer
#FUSES NOCPD                    //No EE protection
#FUSES STVREN                   //Stack full/underflow will cause reset
#FUSES NODEBUG                  //No Debug mode for ICD
#FUSES NOLVP                      //No Low Voltage Programming on B3(PIC16) or B5(PIC18)
#FUSES NOWRT                    //Program memory not write protected
#FUSES NOWRTD                   //Data EEPROM not write protected
#FUSES IESO                     //Internal External Switch Over mode enabled
#FUSES FCMEN                    //Fail-safe clock monitor enabled
#FUSES PBADEN                   //PORTB pins are configured as analog input channels on RESET
#FUSES NOWRTC                   //configuration not registers write protected
#FUSES NOWRTB                   //Boot block not write protected
#FUSES NOEBTR                   //Memory not protected from table reads
#FUSES NOEBTRB                  //Boot block not protected from table reads
#FUSES NOCPB                    //No Boot Block code protection
#FUSES MCLR                     //Master Clear pin enabled
#FUSES LPT1OSC                  //Timer1 configured for low-power operation
#FUSES NOXINST                  //Extended set extension and Indexed Addressing mode disabled (Legacy mode)
#FUSES PLL5                     //PLL PreScaler

#use delay(clock=20000000)
#use rs232(baud=9600,parity=N,xmit=PIN_C6,rcv=PIN_C7,bits=9)

#define ICM_ID7   PIN_D7      //DATA COMING
#define ICM_ID6   PIN_D6      //HEXA/#CODEB
#define ICM_ID5   PIN_D5      //#DECODE
#define ICM_ID4   PIN_D4      //#SHUTDOWN
#define ICM_ID3   PIN_D3      //RAM BANK SELECT
#define ICM_ID2   PIN_D2
#define ICM_ID1   PIN_D1
#define ICM_ID0   PIN_D0

#define ICM_WRITE  PIN_E1
#define ICM_MODE   PIN_E0

#define ICM_PORT(value)   output_d(value)

#include "ICM7228.c"

void main()
{
   int data1[8]={0x38,0x77,0x6F,0x54,0x77,0x1E,0x30,0x78};  //It writes LAgnAJit
   int data2[8]={1,2,3,4,12,11,13,14};
   setup_adc_ports(NO_ANALOGS|VSS_VDD);
   setup_adc(ADC_OFF);
   setup_psp(PSP_DISABLED);
   setup_wdt(WDT_OFF);
   setup_timer_0(RTCC_INTERNAL);
   setup_timer_1(T1_DISABLED);
   setup_timer_2(T2_DISABLED,0,1);
   setup_timer_3(T3_DISABLED|T3_DIV_BY_1);
   setup_comparator(NC_NC_NC_NC);
   setup_vref(FALSE);

   display_digits_nd(data1);        //No decode mode
   delay_ms(1500);     
   update_single_digit_nd(1,0);     //Clears the 1st position as it is 0 in the no decode mode
   delay_ms(1500);
   display_digits(data2,4,0,0);   //Decode as Code B, Decimal at 4th place
   delay_ms(1500);
   display_digits(data2,2,1,0);   //Decode as Hex, Decimal at 2nd place
   delay_ms(1500);
   update_single_digit(1,6,0);   //Update the 1st digit to '4'

}


The source code and the Proteus design simulation can be found from the below links

http://rapidshare.com/files/232024658/ICM7228_Interfacing.zip

http://ifile.it/2wd9c6q
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> Code Library All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group