How many ports are available in PIC18?

How many ports are available in PIC18?

It has total 40 pins. Out of these 40 pins, 34 pins can be used as input output pins. These pins are grouped into five which are called PORTS denoted by A, B, C, D and E….USE INPUT OUTPUT PORTS OF PIC18F452 MICROCONTROLLER.

Bit0 RB0 Bit1 RB1
I/O I/O
TTL/ST TTL/ST
INT0 INT1

Which port of pic18 are bit addressable?

Which of the ports act as the 16 bit address lines for transferring data through it? Explanation: PORT 0 and PORT 2 are used as the 16 bit address lines where PORT0 act as lower bit address lines and PORT 2 as higher bit address lines.

Which register defines the port direction?

The Data Direction Register (DDRx) determines whether the pins operate as inputs or outputs. The port output register (PORTx) determines the actual value set on each pin when it’s being used as an output. The port input register (PINx) is used for reading input values.

When to use Lat register and when port on Pic?

I remember the tris settings on PIC platforms easily because Output is 0 (O) and Input is 1 (I). The simplest rule, applicable 99% of the tine on devices which have LATx addresses, is to use LATx (or LATxn) whenever you are writing a port, or reading a value which will be used in computing a value to be written back to a port.

How to configure port pins in Pic I / O?

Before reading/writing the data, the port pins should be configured as InputOutput . PORTB = 0xff; // Make all PORTB pins HIGH. PORTC = 0x00; // Make all PORTC pins LOW.. PORTD = PORTB; // Read the data from PORTB and send it to PORTD. After knowing how to configure the GPIO ports, its time to write a simple program to blink the Leds.

What is the I / O register in PIC used for?

This register is used to configure the PORT pins as Input or Output. Writing 1’s to TRISx will make the corresponding PORTx pins as Input. Similarly writing 0’s to TRISx will make the corresponding PORTx pins as Output. TRISB = 0xff; // Configure PORTB as Input.

What are the registers associated with each port?

Each Port is associated with 2 registers for direction configuration (Input/Output) and for Read/Write. note: Here ‘x’ could be A,B,C,D,E so on depending on the number of ports supported by the controller. Before reading or writing the data from the ports, their direction needs to be set.