Tuesday, May 18, 2010

Interrupts' and their usage in pic microchip circuit design

 

1. What is an interrupt?
Basically CPU executes the instructions of the program one by one, doing what it is told in a precise and linear way. An interrupt disturbs this order. Coming maybe when least expected, its function is to alert the CPU that some significant external event has happened, to stop it from what it is doing and force it (at greatest speed possible) to respond to what has happened. Originally this was applied to allow emergency external events to get the attention of the CPU, emergencies like power failure, the system overheating or major failure of a subsystem. Then CPU takes necessary actions

2. What is an ISR? What command is used in PIC to return from an ISR?
ISR is interrupt service routine so that basically handle the necessary actions should be taken when some interrupt happens. We can use ISR by configuring following few steps
ü    Start the ISR at the interrupt vector, location 0004
ü    Enable the interrupt that is to be used, by setting the enable bit in the INTCON register
ü    Set the Global Enable bit, GIE
ü    Clear the interrupt flag within the ISR

End the ISR with a retfie instruction. RETFIE is exactly like a return, but it also sets the global interrupt enable (GIE). When a hardware interrupt occurs, it clears GIE and executes what amounts to a CALL instruction. Using RETFIE allows us to enable interrupts and return to the main program all in one step

3. What is Interrupt Latency?
The purpose of the interrupt is to attract the attention of the CPU quickly, but actually how quickly does this happen? The time between the interrupt occurring and the CPU responding to it is called the latency. Actually this is based on hardware configurations of the device

4. What are Interrupt flag bits and mask bits?

Flag bits-The occurrence of the interrupt, even if it is only momentary, is thus recorded. The output of the bistable, the latched version of the interrupt, is called the interrupt flag. This is then gated with an enable signal, Interrupt is enable. Basically we checked flag bits to detect weather interrupt is occurs or not

Mask bits- These bits are used to select which interrupts can be enable. Some interrupts can turn off and turn on. So do that we can use those bits. The action of disabling an interrupt is sometimes called masking. some microcontrollers have interrupts that cannot be masked. These are always external and are used to connect to external interrupt signals of the greatest importance

5. What is the bit that needs to be set in order to enable External interrupt on RBO (0th bit of PortB)?
    bsf intcon,inte
    And we must select global interrupt enable bit

6. What are timers? What is a pre-scalar?
We can use timers to maintain periodic events. Timers provide the timing for a range of activity such as motor controlling and various other applications
        The external input path includes the option of inverting the signal with the     Exclusive OR gate, the inversion being controlled by bit T0SE which is appear in     option register. The output of the first multiplexer branches before reaching a     second multiplexer. This selects     either a direct path or the path taken through a     programmable prescaler.we can set 1 trigger for 255 triggers by setting this
7. What is a watch dog timer?
Big problem of computer system is that the software fails in some way and that the system locks up or becomes unresponsive. In a desktop computer such lock-up can be annoying and one would normally have to reboot. In an embedded system it can be disastrous, as there may be no user to notice that there is something wrong and maybe no user interface anyway. If we enable this timer it’s perioditically counting up and it reaches top value of it then it reset the program (reset means go to the beginning of the program) if we neet to avoid reset we have to clear that by our program time to time.

No comments:

Post a Comment