This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

SN74HC165: Reading serial output from a shift register IC

Part Number: SN74HC165
Other Parts Discussed in Thread: SN74LV8154,

Hey, everyone!

I am using SN74HC165 shift register IC for reading parallel output data from a binary counter IC (SN74LV8154). How do I read the serial data output from this IC? Is it through the RX pin?

Thanks and regards<
Apurv

  • Hey Apurv,

    It's serial data can be read by GPIOs as well, its not required for the data to be read through an RX pin.

  • Hi, thanks for replying.

    How can we read the serial data from a GPIO?

    Regards,
    Apurv

  • If you have enough free GPIOs for the eight data bits and the control signals, you can connect the '8154 directly to your microcontroller.

    If you want to use the '165, you can connect it to any SPI peripheral of your microcontroller (configure it for mode 1). You still need two GPIOs to control the SH/LD and CLK INH pins. It would also be possible to do it manually, but then you'd have to implement the SPI protocol yourself.

  • Hello!

    I have written this code for SN74LV8154 binary counter IC but it is not counting continuously, it resets at 7 or sometimes at a lower value only.

    // include files
    #include "HL_sys_common.h"
    #include "HL_gio.h"
    #include "HL_sci.h"
    #include "HL_het.h"
    #include <stdio.h>

    #define GAL 2
    #define GAU 18
    #define GBL 16
    #define GBU 30
    #define RCLK 14
    #define CCLR 12
    #define CLK 22

    char count[20];

    void main()
    {
    unsigned long freq = 0;
    uint8 b0,b1,b2,b3,b4,b5,b6,b7,b8,b9,b10,b11,b12,b13,b14,b15,b16,b17,b18,b19,b20,b21,b22,b23,b24,b25,b26,b27,b28,b29,b30,b31;

    // Initialize GIO driver
    gioInit();

    // Initialize SCI driver
    sciInit();

    // Initialize HET driver
    hetInit();

    // setting HET1 driver pins as output
    gioSetDirection(hetPORT1, 0xFFFFFFFF);

    //setting GIOA and GIOB driver pins as input
    gioSetDirection(gioPORTA, 0x00000000);
    gioSetDirection(gioPORTB, 0x00000000);

    // initialization of the register
    gioSetBit(hetPORT1, GAL, 1);
    gioSetBit(hetPORT1, CCLR, 0);
    gioSetBit(hetPORT1, GAU, 1);
    gioSetBit(hetPORT1, GBL, 1);
    gioSetBit(hetPORT1, GBU, 1);
    gioSetBit(hetPORT1, RCLK, 0);
    gioSetBit(hetPORT1, CCLR, 1);
    gioSetBit(hetPORT1, CLK, 0);

    while (1)
    {
    freq = 0;

    // set CLOCK pulse
    gioSetBit(hetPORT1, CLK, 1);
    gioSetBit(hetPORT1, CLK, 0);

    // set RCLK pulse
    gioSetBit(hetPORT1, RCLK, 1);
    gioSetBit(hetPORT1, RCLK, 0);

    // read GBU byte
    gioSetBit(hetPORT1, GBU, 0);

    // read bits
    b31 = gioGetBit(gioPORTB, 3);
    freq = freq|b31;
    freq<<=1;
    b30 = gioGetBit(gioPORTB, 2);
    freq = freq|b30;
    freq<<=1;
    b29 = gioGetBit(gioPORTA, 7);
    freq = freq|b29;
    freq<<=1;
    b28 = gioGetBit(gioPORTA, 6);
    freq = freq|b28;
    freq<<=1;
    b27 = gioGetBit(gioPORTA, 5);
    freq = freq|b27;
    freq<<=1;
    b26 = gioGetBit(gioPORTA, 2);
    freq = freq|b26;
    freq<<=1;
    b25 = gioGetBit(gioPORTA, 1);
    freq = freq|b25;
    freq<<=1;
    b24 = gioGetBit(gioPORTA, 0);
    freq = freq|b24;
    freq<<=1;

    // set GBU to HIGH again
    gioSetBit(hetPORT1, GBU, 1);


    // read GBL byte
    gioSetBit(hetPORT1, GBL, 0);

    // read bits
    b23 = gioGetBit(gioPORTB, 3);
    freq = freq|b23;
    freq<<=1;
    b22 = gioGetBit(gioPORTB, 2);
    freq = freq|b22;
    freq<<=1;
    b21 = gioGetBit(gioPORTA, 7);
    freq = freq|b21;
    freq<<=1;
    b20 = gioGetBit(gioPORTA, 6);
    freq = freq|b20;
    freq<<=1;
    b19 = gioGetBit(gioPORTA, 5);
    freq = freq|b19;
    freq<<=1;
    b18 = gioGetBit(gioPORTA, 2);
    freq = freq|b18;
    freq<<=1;
    b17 = gioGetBit(gioPORTA, 1);
    freq = freq|b17;
    freq<<=1;
    b16 = gioGetBit(gioPORTA, 0);
    freq = freq|b16;
    freq<<=1;

    // set GBL to HIGH again
    gioSetBit(hetPORT1, GBL, 1);


    // read GAU byte
    gioSetBit(hetPORT1, GAU, 0);

    // read bits
    b15 = gioGetBit(gioPORTB, 3);
    freq = freq|b15;
    freq<<=1;
    b14 = gioGetBit(gioPORTB, 2);
    freq = freq|b14;
    freq<<=1;
    b13 = gioGetBit(gioPORTA, 7);
    freq = freq|b13;
    freq<<=1;
    b12 = gioGetBit(gioPORTA, 6);
    freq = freq|b12;
    freq<<=1;
    b11 = gioGetBit(gioPORTA, 5);
    freq = freq|b11;
    freq<<=1;
    b10 = gioGetBit(gioPORTA, 2);
    freq = freq|b10;
    freq<<=1;
    b9 = gioGetBit(gioPORTA, 1);
    freq = freq|b9;
    freq<<=1;
    b8 = gioGetBit(gioPORTA, 0);
    freq = freq|b8;
    freq<<=1;

    // set GAU to HIGH again
    gioSetBit(hetPORT1, GAU, 1);


    // read GAL byte
    gioSetBit(hetPORT1, GAL, 0);

    // read bits
    b7 = gioGetBit(gioPORTB, 3);
    freq = freq|b7;
    freq<<=1;
    b6 = gioGetBit(gioPORTB, 2);
    freq = freq|b6;
    freq<<=1;
    b5 = gioGetBit(gioPORTA, 7);
    freq = freq|b5;
    freq<<=1;
    b4 = gioGetBit(gioPORTA, 6);
    freq = freq|b4;
    freq<<=1;
    b3 = gioGetBit(gioPORTA, 5);
    freq = freq|b3;
    freq<<=1;
    b2 = gioGetBit(gioPORTA, 2);
    freq = freq|b2;
    freq<<=1;
    b1 = gioGetBit(gioPORTA, 1);
    freq = freq|b1;
    freq<<=1;
    b0 = gioGetBit(gioPORTA, 0);
    freq = freq|b0;

    // set GAL to HIGH again
    gioSetBit(hetPORT1, GAL, 1);

    printf("%d\r\n", freq);
    }
    }

     

    Where am I going wrong?

    Regards,
    Apurv

  • Hi Apurv,

    Unfortunately, we don't debug code in this forum. If Clemens is available for this then that's fine, but I need schematics and scope shots that show the device not working in the manner you expect. This will provide more insight to see if the device has been damaged or if there are issues with the implementation. If you are able to provide these things then I will be able to support you further.  

  • I do not know anything about the microcontroller you're using, so I cannot say anything about your code.

    But your description ("resets at 7 or sometimes at a lower value") sounds as if there is something wrong with the clock or the clear inputs. For that, schematic and scope/logic analyzer shots are necessary.