Author Topic: Shifty Register behaviour  (Read 993 times)

0 Members and 1 Guest are viewing this topic.

Offline PerranOakTopic starter

  • Frequent Contributor
  • **
  • Posts: 552
  • Country: gb
Shifty Register behaviour
« on: March 15, 2021, 04:31:54 pm »
I have a uC connected to a 74HC595 shift register.

One GPIO0 is connected to HC595 "SER" (serial input) and GPIO1 is connected to both SRCLK and RCLK, i.e. tied together.

This simple programme will only work (it just runs through 0-255 to show-up on the LEDs attached to the HC595 outputs) if I add-in the last "pulse" just before the delay (the delay just aids viewing):
Code: [Select]
    while(1)
    {
        for (int display = 0; display < 256; display++)
        {
            for (int count = 0; count <8; count++)
            {
                GPIObits.GP0 = (display >> count) & 1;
                GPIObits.GP1 = 1;
                GPIObits.GP1 = 0;
            }
            GPIObits.GP1 = 1;
            GPIObits.GP1 = 0;
            __delay_ms(1000);
        }
    }

Without this extra, the numbers are not shifted far enough by one place.

Is this because the RCLK requires the extra pulse to copy the shifted bits into the output "stage"?

Cheers.
You can release yourself but the only way to go is down!
RJD
 

Offline langwadt

  • Super Contributor
  • ***
  • Posts: 5039
  • Country: dk
Re: Shifty Register behaviour
« Reply #1 on: March 15, 2021, 04:41:06 pm »
the output of the shift register will change slightly after SRCLK, so the when SRCLK and RCLK happens at the same time the output register will latch the data right before the shift
 

Offline Jope

  • Regular Contributor
  • *
  • Posts: 111
  • Country: de
Re: Shifty Register behaviour
« Reply #2 on: March 15, 2021, 04:43:30 pm »
Quote from the datasheet (Philips), title page: "If both clocks are connected together, the shift register will always be one clock pulse ahead of the storage register."
 

Offline PerranOakTopic starter

  • Frequent Contributor
  • **
  • Posts: 552
  • Country: gb
Re: Shifty Register behaviour
« Reply #3 on: March 15, 2021, 05:11:47 pm »
So, before I added the extra pulse it was “waiting” for another clock pulse. Cheers.
You can release yourself but the only way to go is down!
RJD
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf