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.

LAUNCHXL2-RM57L: Reading parallel data from a binary counter

Part Number: LAUNCHXL2-RM57L
Other Parts Discussed in Thread: SN74LV8154, HALCOGEN

Hey, everyone!

I am using SN74LV8154 IC to read high-speed digital pulses from a photon counting module. How can I read parallel data directly into the microcontroller?

or will it better and faster if I use a PISO shift register?

Thanks and regards,
Apurv

  • Hi Apurv,

    GPIO or NHET can be used to interface with SN74LV8154 IC. I don't know how to use SN74LV8154 device. Please check with experts in logic forum:

    https://e2e.ti.com/support/logic/f/151

  • Hi!

    I am connecting 8-bit parallel data to the GPIO pins. How to read each of them and write to particular bit positions of a variable?

    Thanks,
    Apurv

  • Hello,

    RM57 has 16 GIO pins: GIOA[8:0] and GIOB[7:0]. If you use GIOA[7:0] to interface this SN74x device. Please enable GIOA module in HALCOGen. HALCOGen is a code generation tool for Hercules MCUs.

    1. Under GIO->PORT A Tab, check "DIR" for all the 8 GIO pins if you use those pin as OUTPUT, or uncheck "DIR" if you use those pins as INPUT.

    2. Click FILE->Generate Code, the tool will generate GIO driver for you.

    You can call gioSetPort(gioPORT_t *port, uint32 value) to write data to this GIO port (8 bits), or call gioGetPort(gioPORT_t *port) to read data from this GIO port.

    You can also write/read a particular bit by calling gioSetBit(gioPORT_t *port, uint32 bit, uint32 value), or gioGetBit(gioPORT_t *port, uint32 bit).

  • 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

  • Hello Apurv,

    The bxx (b0...b24) is either 0 or 1. what does "\"  in freq=freq\bx do?

  • Hello,

    That is actually 'freq = freq|bx' for bitwise OR operation.

    Regards,

    Apurv

  • Hello,

    From MCU perspective, the code is fine. But I am not familiar with the read/write protocol of SN74LV8154 device.