Help Using 74HC594 Shift Register (Please)

Feb 27, 2005 2 Replies

I've been trying to interface a SN74HC594 chip to an AVR 2313 (using avr-gcc) and having a tough time with it.



I have the following function, but it appears as if only the MSB get's set every time it's called.


void write7SegChar(char displayValue) {



// Turn bit on PORTX |= BIT(x) // Turn bit off PORTX &= ~BIT(x) // Toggle bit PORTX ^= ~BIT(x) // // Load PB0 with serial value (MSB First) // Pulse SCLK (PB1) with each value // Pulse RCLK (PB2) after all eight bits are gone // // PB3 is RCLR // PB4 is SCLR


PORTB &= ~(_BV(PB3) | _BV(PB4)); // bring RCLR & SCLR LOW for clear PORTB |= (_BV(PB3) | _BV(PB4)); // bring high again



for (int i = 0; i < sizeof(char); i++) { if((displayValue


Presuming that it's #define BIT(a) (1

That was the problem. Thank you!

The rub is I wasn't even trying to make it portable. That was simply force of habit and not thinking it thru.

I really appreciate the second pair of eyes spotting the obvious problem!

Thanks again.

Kevin

Join the Discussion

Have something to add? Share your thoughts — no account required.

Didn't find your answer?

Ask the community — no account required