all LED fluctuation problem with 74hc595 interface

hi
I am using 74hc595 shift register interfaced with freescale HCS12 controller.i am using 3 74hc595 Ic for interfacing anf I am glowing 20 LEDs using it.
My problem is that when I am setting single LED at a time.This led is setting on correctly but I am getting fluctuations on all LEDs. my code is like this .``

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;
DOes anyone know what is the problem ?n how can I get single LED on at at ime with no fluctions on other LEDs.

Maybe you can better look at a constant current led driver chip, which is better suited for the job (I just got a MAX7315AUE working haven't tried the constant current part yet) .
Also it's best to use leds from the same batch.

hi
Thanks for the reply.Right now I am using DS2004 IC to connect o/p of 74hc595 to LEDs.Can there be some problem with this IC also?
Also, I have noted one thing that this problem comes only first time. amd when I switch off the power and start again,this problem diasappears.
So I just want to know is this issue related with the hardware,because I feel coding part is correct.

If you use the 595 there are extra control lines which can shut off the outputs at startup. This could prevent some unwanted flicker like this.

hi
can u explain a little more about which control lines u are talking about and how to use them.

With extra ICs you need decoupling capacitors on each IC:-
http://www.thebox.myzen.co.uk/Tutorial/De-coupling.html

The control lines are the output enable that will put the outputs into tri state (high impedance) mode.