INTERFACING SWITCH WITH PIC18F4550


Difference between PIC16F I/O and PIC18F I/O:

 PIC 16F Microcontrollers  have two registers to control IO pins, which are TRIS and PORT. TRIS is used to control direction (Input or Output) of each IO pin while PORT is used to Write or Read data from IO pins. Whereas in 18F PIC Microcontrollers there is an additional register, LAT. LAT stands for Port Latch. As in 16F, 18F also uses TRIS register to control direction of each IO pin. LAT register is used to write Output and PORT register is used read Inputs.

Writing Bit by Bit :


TRISC.F0 =1;    // makes 0th bit of PORTC Input
TRISC.F1 =0;   // makes 1st  bit of PORTC Output

PORTB.F3 =1; // Makes 3rd bit of PORTB at Logic High
PORTB.F7 =0; // Makes 7th bit of PORTB at Logic Low 


Mikro C Code for Interfacing Switch :

Figure1: Mikro C code

Simulation :

Figure 2 : Switch Interface with PIC18F4550


                                   

Comments

Popular posts from this blog

555 Timer Astable mode, Lt spice simulation, and real-time testing

Exploring USB Device Detection with Arduino and USB Host Shield

PIC12F675 LED Blinking Code