Sunday, 23 March 2014

Masked inputs with PIC16F88 - FlowCode - LED & Switch Simulation

Here we are using Flow Code Simulation Software for Programming and Testing  with PIC16F88 for switching LED ON or OFF .Here is the basic program for starters.In this masking of Inputs is used.

Flow code program:

In video you will be able to see stepwise execution of program and their effect on LED array as they blink.You will notice only alternate LEDs are blinking and rest are not even if switching on the Toggles s/w.

Here is the complete list of projects:
Tutorials for Flow Code Programming and Simulation

Basic Theory Of Input Pins:- Most of a microcontroller’s I/O pins can be configured as an output or an input. Part 2 described the basics when a pin is configured as an output. This section describes it when it is configured as an input. A special register will control if a pin is an input or output. You need your program to set up the port direction registers as an early step when power is applied to the chip or it comes out of reset

I/O pins are usually configured in groups of 8 bit I/O ports. The program can read the port and will get a value between 0 and 255 depending on the states of the input pins. In assembly language programming there will usually be op code instructions that allow reading a single pin of a port.

C compilers will usually implement single bit functions as well. I/O functions are not defined in standard K&R C, and each compiler handles them a little differently. Otherwise the programmer will have to read the entire port and mask off the other bits.

A pin with a low voltage (ideally 0 volts) will read as a logical 0. A pin with a voltage near Vcc (or Vdd) will read as a logic 1. As a first approximation, any input less than half of Vcc will read as a 0, and any input over Vcc/2 will read as a 1.

Pull ups and pull downs:- Sometimes you want an input to read as a 1 or 0 as a default. Suppose you have a sensor on a cable that plugs into your device. It is possible that the user will disconnect the cable. If the input pin is left floating, it might sometimes read as a 1, sometimes as a 0. Your code might interpret this as changes from a sensor and not act the way you want.Putting a pull up resistor will set the input voltage near Vcc and it will read as a 1. A pull down resistor will bring the voltage near 0V, and it will read as a zero.

Switching between Input and Output Mode:- In some applications you may want a pin to be an input some of the time, and an output at other times. An example is where the microcontroller is communicating with another system or IC.

Sometimes the microcontroller is sending data to another IC, and at other times the IC is sending data to the microcontroller. I2C and Two Wire Interfaces are common examples where an I/O pin is used as both an input and output.One thing to keep in mind is that some microcontrollers require one or more clock cycles after a direction change before the data on the pin can be trusted.

Flow code Simulation and how to do Video Tutorial:

You can Download Flow Code Program File :
C Code
ASM Code
Hex Code
Flow Code Program

No comments:

Post a Comment

Readers' Choice