NEED HELP 8051->SDCC AND A 4014 CMOS

Help
2005-01-10
2013-03-12
  • marekswierzy

    marekswierzy - 2005-01-10

    HI Everyone i need your Help, i've tryed to read data from a 4014 CMOS 8 Bit Shift register.
    The data ist parallel on the pins P0 - P1 of the 4014.

    P2_2 = 1; // Serial out

    P2_7 = 1; // P/S\ P2_6 = 0; // CLK
    P2_6 = 1; // CLK
    P2_7 = 0; // P/S\

    for(i=0;i<8;i++)
    {

    P2_6 = 0; // CLK
    w1 = w1 << 1; //shift left
    if(P2_2==0)
    {
    w1 |=0;
    }
    else if(P2_2==1)
    {
    w1 |=1;
    }
    P2_6 = 1; // CLK

    PLS HELP ME....
    (Sorry for my English, i hopp u will understand me)

     
    • Brian Cherdak

      Brian Cherdak - 2005-01-11

      well for starters, double check your data sheet.  Looks to me like p/s need to be 0 to shift the parallel inputs in.

      P2_7 = 0;  // Reset P/S
      P2_2 = 1   // Set I/O pin to 1, w/Weak Pullup

      for (i = 0; i < 8; i++)
      {

         // Generate the clock
         P2_6 = 0;
         P2_6 = 1;
         P2_6 = 0;     // not fastest, but it always works

         // Shift Storage Variable
         w1 << 1;

         // Add if input is 1
         PinVal = P2_2;
         if (PinVal)
         {
            w1 += 1;
         }
      }

      Note that you don't need the else case since the bit is either zero or one.  Also, note that you compared the value of the data bit twice.  This means you read its value at two different times.  The distinction is that in software, variables don't change unless you change them.  But in hardware, signals change all the time so, if you want to comapre a signals value multiple times, assign it to a variable and make multiple comparisons on the variable.

      That, by the way, is the difference between electrical engineering and computer science.

      Best Luck

      Brian

       
    • Maarten Brock

      Maarten Brock - 2005-01-11

      // Shift Storage Variable
      w1 << 1;

      Should be:

      w1 <<= 1;

       
    • marekswierzy

      marekswierzy - 2005-01-11

      Thanks to everyone, it works fine!

       

Log in to post a comment.