View previous topic :: View next topic |
Author |
Message |
FreakShow!
Joined: 13 Feb 2012 Posts: 21
|
RA5 Not acting as general output |
Posted: Mon Feb 13, 2012 7:20 pm |
|
|
Hi,
Trying to run two Stepper motors off a PIC16F887.
One stepper motor works just fine, but the second does not. This I've worked out is due to the fact that RA5 (Pin 7) is not outputting a signal like it's meant to, but just staying high at 5V.
I've looked at the data sheets and I think it may just be acting as a comparator output?
I've tried a few things I've found on setting it to not use the comparators such as:
Code: | setup_adc_ports(NO_ANALOGS);
setup_comparator(0x00);
OSCCON = 0b01110101;
|
(Not all together, separately)
But it's just doing exactly the same. It's just this one pin, all the rest are doing what they should.
There must be a simple way of doing this, surely?
Using MPLAB IDE 8.83 and CCS Compiler version 4.3.0.323 |
|
|
dyeatman
Joined: 06 Sep 2003 Posts: 1933 Location: Norman, OK
|
|
Posted: Mon Feb 13, 2012 8:19 pm |
|
|
Quote: | CCS Compiler version 4.3.0.323 |
That's not the compiler version. The version is in the format 4.xxx and is found at the top of your .LST file. _________________ Google and Forum Search are some of your best tools!!!! |
|
|
FreakShow!
Joined: 13 Feb 2012 Posts: 21
|
|
Posted: Mon Feb 13, 2012 8:39 pm |
|
|
Apologies. It is 4.120 |
|
|
newguy
Joined: 24 Jun 2004 Posts: 1907
|
|
Posted: Mon Feb 13, 2012 8:51 pm |
|
|
RA5 on some chips is an open drain output. Consult the data sheet. |
|
|
dyeatman
Joined: 06 Sep 2003 Posts: 1933 Location: Norman, OK
|
|
|
FreakShow!
Joined: 13 Feb 2012 Posts: 21
|
|
Posted: Tue Feb 14, 2012 8:47 am |
|
|
Sorry, but there doesn't seem to be any #Byte.
As to newguy, the data sheet it says that you can use it as a general I/O pin. |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19504
|
|
Posted: Tue Feb 14, 2012 9:24 am |
|
|
OK.
Let's step back. Things potentially on this pin:
1) AN4.
2) Comparator 2 output.
3) Slave select input.
So:
Code: |
setup_adc_ports(NO_ANALOGS);
setup_comparator(NC_NC_NC_NC);
setup_spi(FALSE);
|
Now, immediate comment - your compiler seems to have a fault, with the comparator definitions being _missing_ for this chip. There for the 877A, but not for the 877.
The value to turn off the comparators, is not '0'. It is 0xFF07. The register to control this, is CM2CON0, not 'OSCCON', which is the oscillator configuration register....
So I don't think you are turning the comparator off. Add your own
#define NC_NC_NC_NC 0x0FF07
and try with the setup_comparator line shown.
Best Wishes |
|
|
dyeatman
Joined: 06 Sep 2003 Posts: 1933 Location: Norman, OK
|
|
Posted: Tue Feb 14, 2012 11:27 am |
|
|
Sorry, don't know how the wrong link got into the post so here it is again.
http://www.ccsinfo.com/forum/viewtopic.php?t=33809
I double checked this one... _________________ Google and Forum Search are some of your best tools!!!! |
|
|
|