Seema Saini

problem in interfacing HCS12 with 74HC595 shift register

Discussion created by Seema Saini on Oct 15, 2010
Latest reply on Oct 26, 2010 by Seema Saini

hi everyone

   I have interfaced MC9S12XHZ512 controller with three 74hc595 IC(shift register) to glow multiple LED from Single data input

The code for driving the led is somewhat like

 

 CPU_LED_LATCH =0;
  CPU_LED_ENABLE = 0;
ulVal is the input to drive any LED.
    ucShiftValue = (ulVal >> 16) & 0xff;
    uci=8;
    while (uci > 0)
    {
        
            CPU_LED_SRCLK=0;
      if((ucShiftValue & 0x80)==0x80)
         CPU_LED_DATA=1;
    else
         CPU_LED_DATA=0;
           CPU_LED_SRCLK = 1;
      
        ucShiftValue = ucShiftValue << 1;    // Shift left or one bit
            uci--;
    }
    ucShiftValue = (ulVal >> 8) & 0xff;
    uci=8;
    while (uci > 0)
    {

        CPU_LED_SRCLK=0;
      if((ucShiftValue & 0x80)==0x80)
          CPU_LED_DATA=1;
      else   
         CPU_LED_DATA=0;
    
      CPU_LED_SRCLK = 1;
    ucShiftValue = ucShiftValue << 1;    // Shift left or one bit
        uci--;
   
    }

    ucShiftValue = ulVal & 0xff;
    uci=8;
    while (uci > 0)
    {
      
        CPU_LED_SRCLK=0;      
       if((ucShiftValue & 0x80)==0x80)
        CPU_LED_DATA=1;    
      else    
         CPU_LED_DATA=0;
       CPU_LED_SRCLK = 1;
    
        ucShiftValue = ucShiftValue << 1;    // Shift left or one bit
          uci--; 
        
    }
       CPU_LED_LATCH=1;

The problem is the that when I am setting single LED on. I am getting fluctuating output on other LEDs also.say if in above code ulVal=1;

   I will get constant o/p on first LED and it is correct.But I am getting fluctuations on other LEDs as well.

DOes anyone know what is the problem ?n how can I get single LED on at at ime with no fluctions on other LEDs.

 

Regards

SARY

Outcomes