0
\$\begingroup\$

Good day everybody!

So I have a LED clock circuit, which I designed, powered by an atmega328p xmini, and whatever I do the first pin of the shift register which does the current sinking (TPIC6c595D) is always high, so if I want to light up the 2nd LED in my LED matrix the first one lights up as well and so on for the rest of the LED-s.

So my question basically : what could cause this? Without VCC there is no short circuit between the Q0 and VCC pins.The moment I plug in the dev board the short circuit appears. Did I forget to implement pull down resistors? Or the TPIC is faulty?

enter image description here

And here is my code, I don't know if it's important or not, it is a bit spaghetti though.It's a LED test.

#include <avr/io.h>
#include <util/delay.h>
#define HC595_PORT   PORTB
#define HC595_DDR    DDRB
#define HC595_DS_POS PORTB4     //Data pin (DS) pin location
#define HC595_SH_CP_POS PORTB3     //Shift Clock (SH_CP) pin location
#define HC595_ST_CP_POS PORTB2      //Store Clock (ST_CP) pin location
void shiftInit()
{
   //Make the Data(DS), Shift clock (SH_CP), Store Clock (ST_CP) lines output

   HC595_DDR|=((1<<HC595_SH_CP_POS)|(1<<HC595_ST_CP_POS)|(1<<HC595_DS_POS));
}
// change data (DS)lines
#define HC595DataHigh() (HC595_PORT|=(1<<HC595_DS_POS))
#define HC595DataLow() (HC595_PORT&=(~(1<<HC595_DS_POS)))
//Sends a clock pulse on SH_CP line
void shiftPulse()
{
   //Pulse the Shift Clock
   HC595_PORT|=(1<<HC595_SH_CP_POS);//HIGH
   HC595_PORT&=(~(1<<HC595_SH_CP_POS));//LOW
}
//Sends a clock pulse on ST_CP line
void shiftLatch()
{
   //Pulse the Store Clock
   HC595_PORT|=(1<<HC595_ST_CP_POS);//HIGH
   _delay_loop_1(1);
   HC595_PORT&=(~(1<<HC595_ST_CP_POS));//LOW
   _delay_loop_1(1);
}

/*Main High level function to write a single byte to
Output shift register 74HC595.
Arguments:
   single byte to write to the 74HC595 IC
Returns:
   NONE
Description:
   The byte is serially transfered to 74HC595
   and then latched. The byte is then available on
   output line Q0 to Q7 of the HC595 IC.*/

void shiftWrite(unsigned data)
{
   //Send each 8 bits serially
   //Order is MSB first
   for(uint8_t i=0;i<8/*16*/;i++)
   {
      //Output the data on DS line according to the
      //Value of MSB
      if(data & 0b10000000/*00000000*/)
      {
         //MSB is 1 so output high
         HC595DataHigh();
      }
      else
      {
         //MSB is 0 so output high
         HC595DataLow();
      }
      shiftPulse();  //Pulse the Clock line
      data=data<<1;  //Now bring next bit at MSB position
   }
   //Now all 8 bits have been transferred to shift register
   //Move them to output latch at one

}

//Simple Delay function approx 0.5 seconds

void Wait()
{
   for(uint8_t i=0;i<50;i++)
   {
      _delay_loop_2(0);
   }
}

uint8_t shift(uint8_t a)
{
    a=a<<1;
    return a;
}
void main()
{
    unsigned Byte16=0b0000111111110000;
    uint8_t Byte1=0b00000001;
    uint8_t Byte2=0b00000001;
    uint8_t futo=0;


    /*uint8_t reset[2]= {
                        0b00000000,
                        0b00000000
    };*/
   shiftInit(); //Initialise
   while(1)
   {

         shiftWrite(Byte1);   //Write the data to shift register
         _delay_ms(10000);
         shiftWrite(Byte2);
         _delay_ms(10000);
         //Wait();                 //Wait
        shiftLatch();
      /* for(uint8_t i=0;i<2;i++)
       {
           shiftWrite(reset[i]);   //Write the data to shift register
           _delay_ms(5000);
           //Wait();                 //Wait
       }
      shiftLatch();
      _delay_ms(5000);*/
      if(Byte1!=0b10000000)
      {
      Byte1=shift(Byte1);
      futo++;
      }
      else
      {
          if(Byte2!=0b10000000){
          Byte2=shift(Byte2);
          futo=0;
          Byte1=0b00000001;
          }
          else{
              Byte2=0b00000001;
          }

   }

   }
    }

Thank you in advance. Steven

\$\endgroup\$
  • \$\begingroup\$ What does SFRIN connect to? Your diagram is unclear. \$\endgroup\$ – Andy aka Jun 15 at 10:01
  • \$\begingroup\$ Okay it's a bit more clear now, thanks for mentioning. And it's connected to QH'. \$\endgroup\$ – huistbor Jun 15 at 10:12
  • \$\begingroup\$ If this issue has been resolved, please post an actual answer explaining the resolution (vs. your earlier vague hint that a moderator unhelpfully deleted) and then accept it as the solution. Stack exchange sites aren't really able to handle questions which have been simply abandoned, and asking new questions as you have done today while you have questions left in an abandoned state on the site is impolite and makes people hesitant to help you. \$\endgroup\$ – Chris Stratton Oct 29 at 17:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.