CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

Help - PS/2 Driver (Mouse)???

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
fkl



Joined: 20 Nov 2010
Posts: 44

View user's profile Send private message

Help - PS/2 Driver (Mouse)???
PostPosted: Sat May 11, 2013 3:09 am     Reply with quote

Who can help with a working ps/2 driver?
temtronic



Joined: 01 Jul 2010
Posts: 9271
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Sat May 11, 2013 5:01 am     Reply with quote

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

View user's profile Send private message

PostPosted: Sat May 11, 2013 5:56 am     Reply with quote

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

View user's profile Send private message

PostPosted: Sat May 11, 2013 6:05 am     Reply with quote

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

View user's profile Send private message

PostPosted: Sat May 11, 2013 6:33 am     Reply with quote

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

View user's profile Send private message

PostPosted: Sat May 11, 2013 7:05 am     Reply with quote

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

View user's profile Send private message

PostPosted: Sat May 11, 2013 7:56 am     Reply with quote

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

View user's profile Send private message

PostPosted: Sat May 11, 2013 8:29 am     Reply with quote

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

View user's profile Send private message

PostPosted: Sat May 11, 2013 9:01 am     Reply with quote

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

View user's profile Send private message

PostPosted: Sat May 11, 2013 12:10 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Sat May 11, 2013 1:43 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Sat May 11, 2013 4:20 pm     Reply with quote

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

View user's profile Send private message

Help - PS/2 Driver (Mouse)???
PostPosted: Thu May 16, 2013 3:16 am     Reply with quote




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.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group