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.

Having problems using PIC 18F2420/ PIC 18F4520

Status
Not open for further replies.

Maze3

Newbie level 4
Newbie level 4
Joined
Jan 1, 2012
Messages
6
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,310
I have a problem knowing when to use port A /B/C or D and when to use ADCON and INTCON, and what is the job of TRIS?
 

Hi,

There are no hard and fast rules as to what ports you use, though generally PortA is handy for inputs /adc, PortB for outputs and / or Inputs with interrupts.
PortC for data transmission like USART,SPI,I2C and PortD for General purpose i/o - typically a lcd.

TRIS sets the Direction of a Port, 0 for Output 1 for Input.

However for Ports with the ADC function, need to be switched to Digital function with the ADCON1 instruction as they default to Analogue Inputs at Power on.

See the datasheet I/O Port section for code examples.

INTCON relates to enabling the Interrupt functions of various things including PORTB interrupts.
 
  • Like
Reactions: Maze3

    Maze3

    Points: 2
    Helpful Answer Positive Rating
If this confuses you now, I suggest you get some tutorial on PIC to get you started before going into anything deeper.

To answer you question:
You decide what port to use according to your design requirements. As a general digital input/output it makes no difference, tho there are some limitations to consider because all internal hardware (PWM, UART, ADC, etc.) is multiplexed over port pins. For example if you want to use UART, than PORTB pins 6 & 7 (depends on mcu) must be used to allow UART to communicate with the outside, and those pins are not available as general digital I/O.
TRIS registers are used to set direction on corresponding port pins (input or output). For example TRISA=0b00001111 will set pins 0,1,2,3 on PORTA as inputs and 4,5,6,7 as outputs.
ADCON registers (ADCON0 and ADCON1) are used to configure the analog-to-digital converter
INTCON registers (together with PIE registers) are used to configure interrupts.
 
  • Like
Reactions: Maze3

    Maze3

    Points: 2
    Helpful Answer Positive Rating
thank you very much, that was very useful
 

Here are a few tutorials to get you started:



The best PIC tutorials online:

**broken link removed**

Study the Midrange PIC tutorials covering both Assembly or C languages. While the tutorials cover the Midrange PIC16F series, 90% is transferable to the 18F series.

BigDog
 
  • Like
Reactions: Maze3

    Maze3

    Points: 2
    Helpful Answer Positive Rating
Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top