Trust us, YOUR problem is NOT with the code.OK, i am doing one thing ....i have connected switch across data and clock for testing code but terminal window is not showing the data iam feeding from switch is there and problem with code?
Trust us, YOUR problem is NOT with the code.OK, i am doing one thing ....i have connected switch across data and clock for testing code but terminal window is not showing the data iam feeding from switch is there and problem with code?
then hardware ?Trust us, YOUR problem is NOT with the code.
void Capture_init()
{
TRISC0 =1; //Make PS2 CLK and DATA Pins as Input
TRISC1 =1;
CCP2CON=0x04; //Capture Every Falling Edge
T1CON=0x04; //Timer1 1:1 Prescale, Internal Clock
TMR1H=0;
TMR1L=0;
CCP2IF=0; //Clear the Interrupt Flag
}
unsigned char Scan_Data()
{
unsigned char Data=0,temp;
while(CCP2IF==0); //Wait for First Falling Edge
CCP2IF=0; //Clear the Flag--Bcoz this is Start Pulse
for(char i=0;i<7;i++)
{
while(CCP2IF==0); //Capture the next 7 bits of data
CCP2IF=0;
temp=RC0;
temp<<=i;
Data|=temp;
}
CCP2CON=0;
__delay_ms(100);
return(Data); //return the data
}
I would actually expect you to post a schematic drawing after this. Preferably drawn in a suited program. Not more software. Remember: First comes the hardware, then comes the software.then hardware ?
OK, i am working on it..
Now i have corrected that problem...I would actually expect you to post a schematic drawing after this. Preferably drawn in a suited program. Not more software. Remember: First comes the hardware, then comes the software.
First RRitesh, I know you have been on this site http://www.computer-engineering.org/ps2protocol/ Here we can read that PS/2 use a synchronous serial protocol Did you absorb ANY of that!! So then using asynchronous aproach. Do you not think that is most likely to fail. If you have no idea of what you do, then you will not be able to create anything either. Spending a lot of time using Google and then posting any code you think may work. And then asking for help will not either work. For crying out loud. Can you not just for once. Gather information, then based on that information. DO SOME CODING ON YOUR OWN. Even how painful you must think it is to actually read the datasheet, and then convert that information into code. Start simple by just setting up the PIC to use synchronous serial protocol. Then read any data from the latter port, convert it a alphanumeric hex string. And then send it to LCD
http://www.youtube.com/watch?v=ICr3ygRsJvE
void initialise_SPI(void);
unsigned char spi_r(void);
void main (){
unsigned char temp ;
init_io();
initialise_SPI();
while(1)
{temp=spi_r();
PORTD=temp;
}
}
void init_io(void){
TRSID=0X00;
TRISC = 0b00011000;
}
void initialise_SPI(){
SSPSTAT=0b01000000;
SSPCON=0b00100100;
SSPEN = 1;
}
unsigned char spi_r(){
unsigned char temp;
while(!SSPIF);
temp=SSPBUF;
return temp;
}
by Jake Hertz
by Duane Benson