Use shift register in PIC 24

Status
Not open for further replies.

srikanth977

Newbie level 5
Joined
Jan 11, 2012
Messages
8
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,349
Hi all!
I am doing an lcd project using the shift register.
To start with the shift register i had written a small code with the circuit diagram.

But i am not getting the output i need. Kindly help

My code:
=========================
#include<p24fj64ga002.h>

#define output PORTBbits.RB15
#define shcp PORTAbits.RA0
#define stcp PORTAbits.RA1



void msdelay(unsigned int del);


int main(void)
{
shcp=0;//initialized the shcp
stcp=0;//initialized the stcp


PADCFG1 = 0xFF; // Make analog pins digital

TRISAbits.TRISA0=0; //for shcp
TRISAbits.TRISA1=0; //for stcp
TRISBbits.TRISB15 = 0; // configure rb15 for data output
TRISBbits.TRISB14=0; //for mclr of shift register

unsigned char value,temp;
unsigned int i;

value=0x01; //in binary it is - 0000 0111

while(1)
{

for(i=0;i<8;i++)
{
msdelay(10);
shcp=0;
msdelay(10);
shcp=1;
output=~value;
value=value>>1; //right shifting by 1 bit
}
stcp=1;
msdelay(20);
stcp=0;
msdelay(6000);

}
}

void msdelay(unsigned int del)
{
unsigned int i,j;
for(i=0;i<=del;i++)
for(j=0;j<=135;j++);
}
===========================================
the circuit is :


in the above images: the output is always 0xff.

Kindly help.

thanks for reading.
 

Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…