Sunday 18 November 2012

Initialization

Before we start to program, bear in mind (not that bear...!!) that we need to initialize the ports for the pic. From the previous tutorial, 16F877A have 33 pin for i/o which means it can be either 33 pin inputs or 33 pins outputs or any combinations that is up to 33 pins. (get the idea?).

Initialization (in my definition of understanding...) have 2 meaning which is:

  1. To tell the PIC on how to define the pins whether it is an input or an output (TRIS function).
  2. To tell what is the initial state of the respected pin for 2 conditions (PORT function) which is:
    • if input - to tell whether it is an active high or active low state.
    • if output - to tell whether the output is initially HIGH or LOW
How to use? Refer to the program below:


  • The first line of the program above tells us that we are using PORTA and all of the pins are used as outputs.
  • The next line tells us that from RA0 until RA1, the output is initially ON and from RA2 until RA7, the output is initially OFF.
Let's try the example below,


  • The first line of the program tells us that we are using PORTB and from RB0 until RB3, it is an input while from RB4 until RB7, the pins are output.
  • The next line tells us that RB7 and RB5 are having output which is initially ON and for the output at RB6 and RB4, it is initially OFF.
  • For RB0 until RB3 which are inputs, the connection are initially to the ground (active high).           

1 comment:

  1. Slot machines machines | JTG Hub
    JTG Slot Machines. JTG Tunnels 부산광역 출장샵 The Tunnels Hotel, Tunnels Hotels, 경주 출장안마 and Tunnels Tunnels Casino in Tunnels, Mississippi 시흥 출장안마 is one of 평택 출장안마 the largest and 충청남도 출장마사지 best known

    ReplyDelete