HI,
I am using uart at 9600 baund rate....assynchronous mode.
I am using uart at 9600 baund rate....assynchronous mode.
Did you connect a PS/2 keyboard directly to the serial port on a PIC?HI,
I am using uart at 9600 baund rate....assynchronous mode.
Is this how you think a PS/2 keyboard communicates?Hi again,
Here it is:
1 start bit. This is always 0.
8 data bits, least significant bit first.
1 parity bit (odd parity).
1 stop bit. This is always 1.
this is to be written in code but the problem is how to clock or data should be capture because clk is generated in device at unknown timing i don't know it perfect..
and how to make logic for parity test?
yes only from device to uC....and clk is generated from device only!Is this how you think a PS/2 keyboard communicates?
Bertus the problem is not lack of information. But rather the OPs lack of willingnes to convey given information into something useful by him self.Hello,
Have a look at these pages:
http://www.networktechinc.com/ps2-prots.html
http://www.computer-engineering.org/ps2protocol/
http://www.fiacopetti.it/pic-ps2interf_en.htm
Bertus
#include <htc.h>
__CONFIG(LVP_OFF & BOREN_OFF & PWRTE_ON & WDTE_OFF & FOSC_HS);
#define _XTAL_FREQ 20000000
void HSerinit(void),Hserout(unsigned char ch);
unsigned char HSerin(void) ;
void main(void)
{
TRISC = 0b10000000;
ADCON1=0X6;
HSerinit();
__delay_ms(200);
while(1)
{
HSerin();
if(RCREG=='b');
{
RC4 =1;
__delay_ms(250);
}
}
}
void HSerinit(void)
{
TRISC = 0b10000000; // TX was an input!
SPBRG = 51; // 20Mhz xtal 9600 BAUD
TXSTA = 0b00110000; //Synchronous mode Slave mode
RCSTA = 0b10010000;//Serial port enabled Enables continuous receive
}
unsigned char HSerin(void)
{ while(!RCIF); // Wait for a character
return RCREG; // return character
}
I read this three times, almost comprehended it but then magic Irish fairies appeared and we got drunk instead.they how to this?
Start at the beginning. Learn how to program, learn how to use a microcontroller, read the relevant information, then, using your understanding from the previous three experiences, write a program that will accomplish what you want instead of asking others to do it for you.Yes, i have seen many link but need help in programming code how to capture the data with device clock?
#include <htc.h>
__CONFIG(LVP_OFF & BOREN_OFF & PWRTE_ON & WDTE_OFF & FOSC_HS);
#define _XTAL_FREQ 20000000
#define CLOCK RC1
//#define DATA RC0
void HSerinit(void),Hserout(unsigned char Data);
unsigned char Scan_Data(void);
unsigned char ch;
void main()
{
//PORTC=0xFF; //Pull up the inputs to High
TRISC4=0;
TRISC0=1;
TRISC1=1;
HSerinit();
__delay_ms(100);
ch='a';
Hserout(ch);
while(1)
{
// ch=Scan_Data(); //Scan for a incoming data
RC4=0;
RC4=1;
__delay_ms(200);
unsigned char Data=0,temp;
if(CLOCK==0); //Wait for First Falling Edge
// CLOCK=0; //Clear the Flag--Bcoz this is Start Pulse
RC4=0;
RC4=1;
__delay_ms(200);
for(char i=0;i<7;i++)
{
RC4=0;
RC4=1;
__delay_ms(200);
while(CLOCK==0); //Capture the next 7 bits of data
//CLOCK=0;
temp=RC0; //DATA using switch
temp<<=i;
Data|=temp;
}
RC4=0;
RC4=1;
__delay_ms(400);
ch=Data;
Hserout(ch);
RC4=0;
RC4=1;
__delay_ms(200);
ch,Data,temp=0;
RC4=0;
RC4=1;
__delay_ms(200);
}
}
void HSerinit(void)
{
TRISC5 = 0;
//Pull up the inputs to High
// TX was an input!
SPBRG = 129; // 20Mhz xtal 9600 BAUD
TXSTA = 0x24; // TXEN and BRGH
RCSTA = 0x90; // SPEN and CREN
}
void Hserout(unsigned char Data)
{
while(!TXIF);
TXREG = Data;
}
void main()
{
TRISC4=0;
TRISC0=1;
TRISC1=1;
HSerinit();
__delay_ms(150);
ch='a';
Hserout(ch);
while(1)
{
RC4=0;
RC4=1;
__delay_ms(200);
RC4=0;
unsigned char Data=0,temp;
while(RC1==0); { RC4=1;
__delay_ms(400);
RC4=0;
__delay_ms(400);
}