74HC/HCT166 shift register datasheet, error...?


Results 1 to 16 of 16

Threaded View

  1. #4
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    3,172


    Did you find this post helpful? Yes | No

    Default

    Bonjour Steve!

    Yup, I thought of that, same with PAUSEUS. I also use a button to shift in new data after I've sent +5V DC to one of the input pins on the 74HC166. Here's all my code, I even left in the indicator LEDs I've been using to display results:


    INCLUDE "MODEDEFS.BAS" ' Serial I/O modes

    ASM
    LIST
    INCLUDE 'M16F62X.INC' ; PM header
    DEVICE PIC16F628, HS_OSC, WDT_OFF, PWRT_ON, MCLR_OFF, LVP_OFF, PROTECT_OFF
    XALL
    NOLIST
    ENDASM

    DEFINE OSC 20 ' Set oscillator speed
    DEFINE SHIFT_PAUSEUS 3 ' Slow down SHIFT in/out commands by 3uSECS
    CMCON = 7 ' Set PORT A pins to digital

    SHFTIQ7 VAR PORTB.0 ' Input data
    SHFTICP VAR PORTB.1 ' Input clock pulse
    SHFTICE VAR PORTB.2 ' Input clock enable
    SHFTIPE VAR PORTB.3 ' Input parallel enable

    BUTTONI VAR PORTA.4 ' Input user entry

    LED1 VAR PORTA.2 ' Bit active indicator
    LED2 VAR PORTA.3 ' Loop indicator

    LOOP VAR BYTE
    DATAI VAR BIT[16]
    HIBIT CON %1
    HIBYTE CON 1

    START: DATAI = 0 ' Initialize variables
    LOOP = 0

    GOSUB REQBUT ' Wait for user input

    LOW SHFTIPE ' Initiate parallel load of bits
    LOW SHFTICE
    GOSUB CYCCLK

    HIGH SHFTIPE ' Initiate serial shift of bits
    LOW SHFTICE
    GOSUB CYCCLK

    HIGH SHFTICE ' Initiate hold of shift registers

    SHIFTIN SHFTIQ7,_ ' Shift in bits from registers
    SHFTICP,_
    LSBPRE,_
    [DATAI\16]

    FOR LOOP = 0 TO 15 ' Check bits for a high bit
    GOSUB BITNUM
    IF DATAI = HIBIT THEN
    GOSUB HIFND
    ENDIF
    NEXT LOOP

    GOTO START ' Restart processing

    FINISH: END ' Terminate processing


    ' SUB-ROUTINES


    REQBUT: GOSUB FLASH ' Process user input
    IF BUTTONI <> HIBYTE THEN GOTO REQBUT
    RESUME

    FLASH: HIGH LED1 ' Indicate waiting for user input
    HIGH LED2
    PAUSE 250
    LOW LED1
    LOW LED2
    PAUSE 250
    RETURN

    CYCCLK: LOW SHFTICP ' Cycle clock pulse
    HIGH SHFTICP
    RESUME

    BITNUM: HIGH LED2 ' Indicate bit number within string
    PAUSE 250
    LOW LED2
    PAUSE 250
    RETURN

    HIFND: HIGH LED1 ' Indicate bit is high
    PAUSE 250
    LOW LED1
    PAUSE 250
    RETURN

    If I jst connect the input pins to the PIC to GND, all the bits are 0, if I connect to +5V DC, all the bits are 1, which is what I expect. I'm stumped.

    Robert
    Last edited by Demon; - 28th January 2005 at 22:12.
    My Creality Ender 3 S1 Plus is a giant paperweight that can't even be used as a boat anchor, cause I'd be fined for polluting our waterways with electronic devices.

    Not as dumb as yesterday, but stupider than tomorrow!

Similar Threads

  1. Active low input?
    By CosMecc in forum mel PIC BASIC Pro
    Replies: 14
    Last Post: - 8th August 2010, 21:31
  2. PIC16F877A pwm use for IR transmission
    By mcbeasleyjr in forum General
    Replies: 0
    Last Post: - 11th July 2009, 19:51
  3. Loop with two motor and 2 sensors
    By MrRoboto in forum mel PIC BASIC
    Replies: 4
    Last Post: - 9th December 2008, 00:40
  4. Optimizing DIV
    By skimask in forum mel PIC BASIC Pro
    Replies: 41
    Last Post: - 22nd September 2008, 05:58
  5. Replacing shift register with PIC
    By TonyA in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 7th April 2008, 19:31

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts