gabeNC
Member
Howdy gents,
Have two 595's working good but when I add the third one, the entire line of 24 leds light up and the animation stops. Scope doesn't show much ripple on the rails but I added another bypass cap close to the 595's just for good measure. Already had two caps on either side of the 7805 and of course on the power pins of the pic. Total current through the regulator is .3 amps.
Seems to be when I solder on the SCK pin is when the problems start. Switched to a different 595 and same result, triple checked connections. Any ideas? Thanks!
Have two 595's working good but when I add the third one, the entire line of 24 leds light up and the animation stops. Scope doesn't show much ripple on the rails but I added another bypass cap close to the 595's just for good measure. Already had two caps on either side of the 7805 and of course on the power pins of the pic. Total current through the regulator is .3 amps.
Seems to be when I solder on the SCK pin is when the problems start. Switched to a different 595 and same result, triple checked connections. Any ideas? Thanks!
Code:
#include <p18f4620.h>
#include <delays.h>
#include <timers.h>
#include <pwm.h>
#pragma config OSC = INTIO67 // Internal oscillator, OSC1 & OSC2 are IO
#pragma config FCMEN = OFF // Fail-safe clock monitor off
#pragma config IESO = OFF // Int-Ext Osc switchover disabled
#pragma config PWRT = OFF // Power-up timer disabled
#pragma config BOREN = OFF // Brown-out reset disabled
#pragma config BORV = 0 // Brown-out voltage maximum
#pragma config WDT = OFF // Disable hardware watch-dog timer control
#pragma config MCLRE = ON // MCLR enabled
#pragma config LPT1OSC = ON // T1 Oscillator enabled
#pragma config PBADEN = OFF // Port B A/D disabled digital on reset
#pragma config CCP2MX = PORTBE // CCP2 MUX
#pragma config STVREN = ON // Stack overflow reset enabled
#pragma config LVP = OFF // Low voltage ICSP disabled
#pragma config XINST = OFF // Enable extended instruction set
#pragma config DEBUG = OFF // Background debugger disabled
// shift register model: ST74HC595B1
#define DataPin PORTAbits.RA0 // SI Serial Data Input
#define ClockPin PORTAbits.RA1 // SCK Clock Input
#define OutputEnable PORTAbits.RA2 // G (output enable)
#define LatchPin PORTAbits.RA3 // RCK Latch
void ShiftOut(unsigned long dat){
unsigned char i;
LatchPin=0;
for(i=0;i<24;i++){
DataPin=dat & 1;
//Nop();
ClockPin = 1;
dat>>=1;
ClockPin = 0;
}
LatchPin=1;
//Nop();
LatchPin=0;
}
// a debug indicator
// should move this from RA4 since 18f can sink and source
void FlashRA4(char time){
LATAbits.LATA4 = 1;
Delay10KTCYx(time);
LATAbits.LATA4 = 0;
Delay10KTCYx(time);
}
void main (void)
{
OSCCON = 0x62; // Int Osc, 4Mhz
while(!OSCCONbits.IOFS); // Wait for osc to be stable
TRISA = 0;
LatchPin = 1;
OutputEnable =1;
FlashRA4(5);FlashRA4(5);FlashRA4(5);
while(1)
{
ShiftOut(0b111111110000000011111111);
Delay10KTCYx(100);
ShiftOut(0b000000001111111100000000);
Delay10KTCYx(100);
ShiftOut(0b111111111111111111111111);
Delay10KTCYx(100);
FlashRA4(10);
}
}