here are my code~in hardware part, I have 16 led that connected to shift register 595 and pic16F877A~after i burnt my coding to pic, how do i do on my hardware 2 display?need what instrument?
//include file
#include <pic.h>
//16F877A configuration
__CONFIG(0x3f71);
#define PORTDIT(adr, bit) ((unsigned)(&adr)*8+(bit))
static bit LED0 @ PORTDIT(PORTD, 0);
static bit LED1 @ PORTDIT(PORTD, 1);
static bit LED2 @ PORTDIT(PORTD, 2);
static bit LED3 @ PORTDIT(PORTD, 3);
static bit LED4 @ PORTDIT(PORTD, 4);
static bit LED5 @ PORTDIT(PORTD, 5);
static bit LED6 @ PORTDIT(PORTD, 6);
static bit LED7 @ PORTDIT(PORTD, 7);
static bit LED8 @ PORTDIT(PORTD, 8);
static bit LED9 @ PORTDIT(PORTD, 9);
static bit LED10 @ PORTDIT(PORTD, 10);
static bit LED11 @ PORTDIT(PORTD, 11);
static bit LED12 @ PORTDIT(PORTD, 12);
static bit LED13 @ PORTDIT(PORTD, 13);
static bit LED14 @ PORTDIT(PORTD, 14);
static bit LED15 @ PORTDIT(PORTD, 15);
unsigned int i; //for loop pause
unsigned int c; //for loop event loop
//pause functions
void pause_1();
void pause_2();
//main function
void main(void)
{
TRISD = 0x00;
PORTD = 0b00000000;
while(1)
{
for(c=0; c<10; c++)
{
//forward
LED0 = 1;
pause_1();
LED0 = 0;
LED1 = 1;
pause_1();
LED1 = 0;
LED2 = 1;
pause_1();
LED2 = 0;
LED3 = 1;
pause_1();
LED3 = 0;
LED4 = 1;
pause_1();
LED4 = 0;
LED5 = 1;
pause_1();
LED5 = 0;
LED6 = 1;
pause_1();
LED6 = 0;
LED7 = 1;
pause_1();
LED7 = 0;
LED8 = 1;
pause_1();
LED8 = 0;
LED9 = 1;
pause_1();
LED9 = 0;
LED10 = 1;
pause_1();
LED10 = 0;
LED11 = 1;
pause_1();
LED11 = 0;
LED12 = 1;
pause_1();
LED12 = 0;
LED13 = 1;
pause_1();
LED13 = 0;
LED14 = 1;
pause_1();
LED14 = 0;
LED15 = 1;
pause_1();
LED15 = 0;
//reverse
LED14 = 1;
pause_1();
LED14 = 0;
LED13 = 1;
pause_1();
LED13 = 0;
LED12 = 1;
pause_1();
LED12 = 0;
LED11 = 1;
pause_1();
LED11 = 0;
LED10 = 1;
pause_1();
LED10 = 0;
LED9 = 1;
pause_1();
LED9 = 0;
LED8 = 1;
pause_1();
LED8 = 0;
LED7 = 1;
pause_1();
LED7 = 0;
LED6 = 1;
pause_1();
LED6 = 0;
LED5 = 1;
pause_1();
LED5 = 0;
LED4 = 1;
pause_1();
LED4 = 0;
LED3 = 1;
pause_1();
LED3 = 0;
LED2 = 1;
pause_1();
LED2 = 0;
LED1 = 1;
pause_1();
LED1 = 0;
LED0 = 1;
pause_1();
};
//re-initalize PORTD
PORTD = 0b00000000;
for(c=0; c<10; c++)
{
PORTD = 0b10101010;
pause_2();
PORTD = 0b01010101;
pause_2();
};
for(c=0; c<10; c++)
{
PORTD = 0b11110000;
pause_2();
PORTD = 0b00001111;
pause_2();
};
for(c=0; c<10; c++)
{
PORTD = 0b11001100;
pause_2();
PORTD = 0b00110011;
pause_2();
};
for(c=0; c<10; c++)
{
PORTD = 0b10000001;
pause_1();
PORTD = 0b01000010;
pause_1();
PORTD = 0b00100100;
pause_1();
PORTD = 0b00011000;
pause_1();
PORTD = 0b00100100;
pause_1();
PORTD = 0b01000010;
pause_1();
};
}
}
void pause_1()
{
for(i=0; i<4000; i++);
for(i=0; i<4000; i++);
};
void pause_2()
{
for(i=0; i<4000; i++);
for(i=0; i<4000; i++);
for(i=0; i<4000; i++);
for(i=0; i<4000; i++);
for(i=0; i<4000; i++);
for(i=0; i<4000; i++);
};
---------- Post added at 10:44 ---------- Previous post was at 10:40 ----------
hai,
11th pin of 74hc595 is data input pin
So, first you set as high all three pins
taht is
bsf portd,0
bsf portd,1 ;data
bsf portd,2
then check the changes in your led.
~~~~bsf is means what??
can u teach me how to write the complete source code that can generate in MPLAB?
if using SPI software how to write..thanks~