Hello,
Can I have some guidance, I have written the code below to drive a set of LEDs attached to a SN74HC595, I am using a PIC16F1825 to drive the SN74HC595.
3 LEDs are attached to the PIC16F1825 to provide feedback that the code is cycling as expected. These all function correctly.
The connection between the PIC and the shift register is as below:
PIC16F1825 SN74HC595
SDO PIN 3 RA4 PIN 14 SER
SDI PIN 9 RA5 Floating Not Connected
SCK PIN 10 RC0 PIN 11 SRCLK
Latch out PIN 11 RA2 PIN 12 RCLK
Common ground and 5V power supply is provided to both the PIC and shift register. no resistors or capacitors are connected between the PIC and the shift register.
LEDs are connected to the 9 outputs of the shift register.
The LEDs attached to the shift register stay lit, but do not cycle off, or make any of the expected patterns.
What am I doing wrong? Thank you in advance.
Code:TxData var BYTE define OSC 4 OSCCON = %01101010 HC_Data var PORTA.4 'SDO HC_Clk var PORTC.0 'SCK HC_latch var PORTA.2 'Digital output LED_YELLOW var PORTA.1 LED_GREEN var PORTC.3 LED_RED var PORTA.0 TRISA = 0 'all digital outputs PORTA = 0 'make all pins low ANSELA = 0 TRISC = %00000010 'all digital outputs except port 1 PORTC = 0 'make all pins low ANSELC = 0 APFCON0 = %01000000 'set SPI pin alternative SSP1STAT = %00000000 SSP1CON1 = %01100010 SSP1CON3 = %00010000 txdata = 0 'SPI output byte pause 200 'prove LED function LED_YEllow = 1 LED_Green = 1 LED_red = 1 pause 200 LED_YEllow = 0 LED_Green = 0 LED_red = 0 Main: 'set up sequence of signals for output LED_Yellow = 1 TxData = %10101010 Gosub Send_Data TXDATA = %00000000 Gosub Send_Data TxData = %10000000 Gosub Send_Data TxData = %01000000 Gosub Send_Data TxData = %00100000 Gosub Send_Data LED_Yellow = 0 LED_gREEN = 1 TxData = %00010000 Gosub Send_Data TxData = %00001000 Gosub Send_Data TxData = %00000100 Gosub Send_Data TXDATA = %00000010 Gosub Send_Data TXDATA = %00000001 Gosub Send_Data LED_GREEN = 0 goto main end Send_Data : SSP1CON1.5 = 0 SSP1CON1.5 = 1 toggle LED_RED PAUSEUS 10 SSP1BUF = TXDATA PAUSEUS 10 HC_Latch=1 pauseus 5 HC_Latch=0 pause 750 return




Bookmarks