Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[SOLVED] Disable ECCP and make PIN Digital Outputs

Status
Not open for further replies.

M.Rehan

Full Member level 2
Joined
Feb 10, 2016
Messages
129
Helped
2
Reputation
66
Reaction score
33
Trophy points
28
Activity points
972
How to disable ECCP Module and make pins Digital Outputs


Capture.PNGCapture1.PNG



Configuration?
 
Last edited:

Hi,

0000 = ECCP OFF

Klaus
 

0000 = ECCP OFF
Klaus


Code C - [expand]
1
2
3
CCPxM<3:0> = 0000 
 
//Capture/Compare/PWM off (resets the module)



what is meant by Resets the module?
Can I apply low and high signals on these pins as digital outputs?
Actually I want to assign all of them as Port Pins
 

Hi,

it resets the capture/compare/PWM module.

As soon as you switch the ECCP module OFF you may use the pins as usual port pins.

***
For further, more detailed discussion please write what microcontroller you refer to and/or give a link to the datasheet (@manufacturer)

Klaus
 
  • Like
Reactions: M.Rehan

    M.Rehan

    Points: 2
    Helpful Answer Positive Rating
MicroController PIC18F46k22
**broken link removed**
 

It seems to me that you need to learn how to read the Microchip data sheets (there are a few conventions they use that you need to understand).
If you look at Tablew 1 of the data sheet yopu reference, you will see the columns are in a very specific order with the function of the ones on the right taking precedence of the ones to the left.
You mention the ECCP which is part of the Capture/Compare/PWM peripheral and the pin assignments are all listed in the 9th column from the left in Table 1. That means that, if it is enabled then the CCP function will take precedence over anything listed for that pin to the left.Now you need to look at the registers in the CCP peripheral that control its operation. Look at the definition Register 14-1 for the CCPxCON register. Along the top row it will tell you if the various bits are readable and/or writable (or undefined/unused) and also the state of the bit after a power-on-reset - typically 0 or 1. In the case of CCPxCON all bits are initially reset to 0.
Now look at the definitions of the various bits listed underneath the diagram and in particular look at the CCPxM bit definitions. You will see that the combination of 0b0000 is listed as "Capture/Compare/PWM off (resets the module)".
From this you can tell two things: 1) if you want the CCP peripheral to be off then make these bits all zero and 2) the peripheral is off by default after a power on reset (and this is nearly always the case for app peripherals).
The next part of your question is how to make a pin a digital output. Again there are 2 parts to this: first is the "analog v digital" question and then the "input vs output" setting. Looking at Section 10 which deals with the I/O ports, right at the start you will see that it mentions at least 4 registers: PORT, LAT, TRIS and (for this particular device) ANSEL.
ANSELx refers to a set of registers that determine if a pin is analog or digital. Look up the register related to the port you are interested in (I'll use ANSELA for this example) and interpreting the top part of the diagram as before you will see that many of the pins are read/write and they are initialised to 1. Looking below the diagram you will see that this means the digital input buffer is disabled; many other data sheets will refer to this meaning that the pin is in analog mode.
If you want to use the pin for an analog function then this is exactly what you want, but if you want to use it for a digital input (and I'd recommend doing this for digital output as well) then you need to set it to 0. It is quite common to see a set of statements at the start of a program such as "ANSELA = 0;" to out all of the ports into digital mode.
Next look at the TRIS register for the port: this determines if the pin is used as a digital input (1) or digital output (0). Again the register documentation shows that the power on reset setting for the TRISx register pins is 1 (input - I remember this a 1 for Input, 0 for Output). As you want you set the pin to output you will need to set the appropriate bit to 0.
Finally you get the PORT and LAT registers. The reason there are two registers here is to get around a nasty problem called "read modify write" (look it up as you really should know what this is about). The golden rule is "read from the PORT, write to the LAT".
As you want to use the pin as a digital output and you have configured the ANSELx and TRISx bits correctly, all toy need to do is to set the LATx bit to whatever value you want to put on the pin.
Susan
 
Thanks Susan for satisfied and helpful answer

referring to section 10.5
Individual pins can be configured as input/output of PORTD
Capture.PNG

It is not mentioned for rest of ports i,e PORTC and PORTB
can these other pins be configured individually input/output or not?
 

Hi,

You refer to section 10.5 Portd registers.

I expect there are similar sentences in the sections for the other ports.

Klaus
 

It is not mentioned for rest of ports i,e PORTC and PORTBcan these other pins be configured individually input/output or not?
Absolutely they can. The register descriptions show each of the 8 bits and the port pins they correspond to. Therefore you can use any of the various ways of setting and clearing the bits individually to set the ports up as you need to.
Susan
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top