View previous topic :: View next topic |
Author |
Message |
fkl
Joined: 20 Nov 2010 Posts: 44
|
Help - PS/2 Driver (Mouse)??? |
Posted: Sat May 11, 2013 3:09 am |
|
|
Who can help with a working ps/2 driver? |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9271 Location: Greensville,Ontario
|
|
Posted: Sat May 11, 2013 5:01 am |
|
|
I'm pretty sure there's a program or two in the 'code library forum'.
You might try using the 'search' feature for this forum as well.
hth
jay |
|
|
fkl
Joined: 20 Nov 2010 Posts: 44
|
|
Posted: Sat May 11, 2013 5:56 am |
|
|
temtronic wrote: | I'm pretty sure there's a program or two in the 'code library forum'.
You might try using the 'search' feature for this forum as well.
hth
jay |
http://www.ccsinfo.com/forum/viewtopic.php?t=46200
not work. |
|
|
dyeatman
Joined: 06 Sep 2003 Posts: 1941 Location: Norman, OK
|
|
Posted: Sat May 11, 2013 6:05 am |
|
|
Another person in the same thread say it works fine so, apparently, you are
doing something wrong. Time for you to troubleshoot and figure out what
mistake you made. He does make a number of comments about
adjustments. You need to follow his directions and get out the
datasheet to figure out the changes required. _________________ Google and Forum Search are some of your best tools!!!! |
|
|
fkl
Joined: 20 Nov 2010 Posts: 44
|
|
Posted: Sat May 11, 2013 6:33 am |
|
|
dyeatman wrote: | Another person in the same thread say it works fine so, apparently, you are
doing something wrong. Time for you to troubleshoot and figure out what
mistake you made. He does make a number of comments about
adjustments. You need to follow his directions and get out the
datasheet to figure out the changes required. |
maybe you're right.
can build a small project and the use of the library, a mouse you should be, you can use any processor. It will be much more constructive. |
|
|
dyeatman
Joined: 06 Sep 2003 Posts: 1941 Location: Norman, OK
|
|
Posted: Sat May 11, 2013 7:05 am |
|
|
BTW, to illustrate my point I just tested his code with an 18F4550, 18F46K22 and
18F452. It worked on all 3 after making adjustments per his instructions.
1. Use a good (valid) interrupt pin definition for MOCLOCK.
2. Output indications (LEDs, pin toggles etc.) they have to be on a "free" I/O
pin, meaning the pin can't be used by another peripheral/function, otherwise
it will have to be disabled.
3. The same is true for MODATA.
4. Double check your wiring. I use a PS2 breakout which makes it easier.
I just looked at your comment on his thread. You do realize pins C0/C1
for that chip are also comparator pins right? _________________ Google and Forum Search are some of your best tools!!!! |
|
|
fkl
Joined: 20 Nov 2010 Posts: 44
|
|
Posted: Sat May 11, 2013 7:56 am |
|
|
dyeatman wrote: | BTW, to illustrate my point I just tested his code with an 18F4550, 18F46K22 and
18F452. It worked on all 3 after making adjustments per his instructions.
|
thank you very much
test too, on 18F4550 - work, but I do not understand why does not work with pic18f14k50
I use for 18F4550
Code: | #define MOCLOCK PIN_B0 //INT_EXT
#define MODATA PIN_B1 |
I use for 18F14k50
Code: | #define MOCLOCK PIN_C0 //INT_EXT
#define MODATA PIN_C1 |
|
|
|
dyeatman
Joined: 06 Sep 2003 Posts: 1941 Location: Norman, OK
|
|
Posted: Sat May 11, 2013 8:29 am |
|
|
Did you see my last question?
Quote: | You do realize pins C0/C1 for that chip are also comparator pins right? |
_________________ Google and Forum Search are some of your best tools!!!! |
|
|
fkl
Joined: 20 Nov 2010 Posts: 44
|
|
Posted: Sat May 11, 2013 9:01 am |
|
|
dyeatman wrote: | Did you see my last question?
Quote: | You do realize pins C0/C1 for that chip are also comparator pins right? |
|
Please tell me the directly thing to do for the code to run pic18f14k50.
Code: | #define MOCLOCK PIN_C0 //INT_EXT
#define MODATA PIN_C1 |
|
|
|
dyeatman
Joined: 06 Sep 2003 Posts: 1941 Location: Norman, OK
|
|
Posted: Sat May 11, 2013 12:10 pm |
|
|
You want it handed to you but, as an educator I would rather you learn.
Hints:
Check the manual for setup_comparator().
The pins also have ADC that needs to be disabled.
From the PIC Datasheet Page 90 section 9.3:
Quote: | Note: On a Power-on Reset, RC<7:6> and
RC<3:0> are configured as analog inputs
and read as ‘0’. |
** When pins don't work break out the datasheet and find out what is connected to those pins **
A little research on your part should get you the rest of the way there. _________________ Google and Forum Search are some of your best tools!!!! |
|
|
fkl
Joined: 20 Nov 2010 Posts: 44
|
|
Posted: Sat May 11, 2013 1:43 pm |
|
|
Code: |
setup_comparator (NC_NC_NC_NC);
setup_adc_ports(NO_ANALOGS);
setup_adc(ADC_OFF);
|
still does not work pic18f14k50
p.s.
on pic18f4550 - work. |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9271 Location: Greensville,Ontario
|
|
Posted: Sat May 11, 2013 4:20 pm |
|
|
Easy way is to get both PICs datasheets and compare pin by pin which peripherals are on the 14k50 that are not on the 4550.
Since the code works on the 4550, it has to be some peripheral on the 14k20 that is not being disabled to allow the program to execute correctly.
Or perhaps a 'configuration' error? clock selection, PLL, wdt,???
hth
jay |
|
|
fkl
Joined: 20 Nov 2010 Posts: 44
|
Help - PS/2 Driver (Mouse)??? |
Posted: Thu May 16, 2013 3:16 am |
|
|
if you add a line that works, but with errors:
Code: |
int mouse_write(unsigned int data, delay) { //WRITE TO MOUSE. POLLING :(
unsigned int i;
unsigned int parity = 1;
output_high(pin_c7);
last_pkt = data;
disable_interrupts(GLOBAL);
output_low(MOCLOCK);
delay_us(90);
output_low(MODATA);
delay_us(35);
input(MOCLOCK);
////+++++++++++++++++++++++++++++++++
while (input(MOCLOCK));
while (!input(MOCLOCK));
output_low(MODATA);
while (input(MOCLOCK));
while (!input(MOCLOCK));
////+++++++++++++++++++++++++++++++++
while (input(MOCLOCK) == 1);
for (i=0; i < 8; i++) {
if (data & 0x01) {
input(MODATA);
} else {
////+++++++++++++++++++++++++++++++++
delay_us(4);
////+++++++++++++++++++++++++++++++++
output_low(MODATA);
}
while (input(MOCLOCK) == 1);
while (input(MOCLOCK) == 0);
parity = parity ^ (data & 0x01);
data = data >> 1;
}
if (parity) {
input(MODATA);
} else {
output_low(MODATA);
}
while (input(MOCLOCK) == 0);
while (input(MOCLOCK) == 1);
input(MODATA);
delay_us(50);
while (input(MOCLOCK) == 1);
clear_interrupt(INT_EXT);
enable_interrupts(GLOBAL);
delay_ms(delay);
return 1;
}
|
Help. |
|
|
|