S Suraj143 Active Member Jan 11, 2012 #1 Guys I need to load a 8 bit value to 74HC595 IC.Please see my code is ok?Its not working. Code: void load_595(short num){ short mask; for(mask=0b10000000;mask>0;mask=mask>>1){ if ((mask & num)>0) { sdata=1; clk_595(); } else{ sdata=0; clk_595(); } } latch_595: slatch=1; delay_us(1); slatch=0; } void clk_595(){ sclock=1; delay_us(1); sclock=0; } I use mikroC.The compilor generates such an asm code that I doubt. It always set bit 7 of the mask register when I shift it right Code: //for(mask=0b10000000;mask>0;mask=mask>>1){ RRF load_595_mask_L0+0, 1 BCF load_595_mask_L0+0, 7 BTFSC load_595_mask_L0+0, 6 BSF load_595_mask_L0+0, 7 Last edited: Jan 11, 2012
Guys I need to load a 8 bit value to 74HC595 IC.Please see my code is ok?Its not working. Code: void load_595(short num){ short mask; for(mask=0b10000000;mask>0;mask=mask>>1){ if ((mask & num)>0) { sdata=1; clk_595(); } else{ sdata=0; clk_595(); } } latch_595: slatch=1; delay_us(1); slatch=0; } void clk_595(){ sclock=1; delay_us(1); sclock=0; } I use mikroC.The compilor generates such an asm code that I doubt. It always set bit 7 of the mask register when I shift it right Code: //for(mask=0b10000000;mask>0;mask=mask>>1){ RRF load_595_mask_L0+0, 1 BCF load_595_mask_L0+0, 7 BTFSC load_595_mask_L0+0, 6 BSF load_595_mask_L0+0, 7
3v0 Coop Build Coordinator Forum Supporter Jan 20, 2012 #2 Did you figure out what the problem was yet ?