Tuesday, July 3, 2012

A Journey By MicroChip...... (part 1)


Journey By MicroChip
( PIC based Micro controller )
                                                Part(1)

Intro
PIC family MicroController:
Microchip is the vendor of the PIC family micro controller which provide three range of micro controller , baseline micro controller(typically below PIC16x ), mid level micro controller, and high performance micro controller.
Baseline microcontroller provide at least an amount of component  which is enough to develop some range of peripheral application development such as temperature sensor.
It is a low power device.
Mid range Micro controller
Midrange micro controller has 14 bit program memory typically PIC16 and PIC12 group are consider as mid range micro controller .
High performance Micro controller
High performance micro controller has wide range of variation. It has a high performance ADC, 32 level  stack interrupt etc. depending on the hardware it has around 79 instruction set.

Fig: Pic Microcontroller
Processor Architecture :
PIC processor follows as Harvard architecture (RISC). According to that the Program and Data are stored in separate storage, accessible via different signals. So, CPU use different address bus, instruction bus  and data bus to execute instruction. Due to that reason it can not access both read write operation at the same time.

Fig: Oscillator
Oscillator :

PIC micro controller needs clock cycle to do its operation. The clock cycle should be  provided to micro controller as a external device  by means of  oscillator. In that sense oscillator is a extern device which provide clock cycle to the micro controller.

Oscillator mode is depend on the device. To select correct device oscillator one should look the device manual. Apart from that typically PIC micro controller select 8  oscillator mode which are as follows :

Id
Name
Meaning
1
LP
Low Frequency Crystal
2
XT
Crystal Resonator
3
HS
High Speed Crystal Resonator
4
RC
External Resistor/Capacitor
5
EXTRC
External Resistor/Capacitor
6
EXTRC
External Resistor/Capacitor with CLKOUT
7
INTRC
Internal 4 MHz Resistor/Capacitor

8
INTRC
Internal 4 MHz Resistor/Capacitor with CLKOUT


Ones who want to buy the oscillator should care of about the frequency and the oscillator type. When it is connected to oscillator micro controller should be configured with appropriate oscillator type. After the micro controller will operate with given oscillator frequency . Point to be noted that one instruction is executed after each 4 clock cycles.
So, micro controller speed is defined by the oscillator frequency.

Example:          Configuring Oscillator according to MPLAB C18 
                         #pragma config OSC = HS
                          or  _CONFIG _HS_OSC
 before using _CONFIG  processor should be define as
                          PROCESSOR pic18xxxx

Watchdog Timer :
Pic micro controller use watchdog timer to monitor the hardware continuously. If something unusual things happens the watchdog timer will restart the program. Eventually a watchdog timer is special timer which will incremented by one at every clock cycle of the internal RC clock pulse. When Watchdogtimer register has an Overflow , an interrupt is called which restart the micro controller. To prevent our program from continuously resetting , program should know the time interval that the watchdog timer needs to count 00 to FF. Knowing that , the program should reset the counter value to 00 before the overflow happens. If some unusual things happens and micro controller is running some part of program continuously (hang on a loop) the watchdog timer will not be reset by the program, In that case , watchdog timer finish its counting , interrupt will be called and the micro controller will be reset again.

          Example :
         
   Configuring Oscillator according to MPLAB C18 
                         #pragma config WDT= ON
                          or  _CONFIG _WDT_ON
   before using _CONFIG  processor should be define as
                          PROCESSOR pic18xxxx

Additional steps :
calculate the RC clock time needed to make overflow of the WDT
Reset the WDT timer register before it finish its counting.



Reliable computing / Malfunction Detection

Fig: Monitoring by watchdog Timer 
Watchdog timer is used to find possible program malfunction and reset the device to ensure reliable computing. It use monitor based scheme where a specific hardware (counter ) is used.
Before enter to specific function block the watchdog timer is set to zero. Then it enter to the functional block and start monitoring. If something is wrong or the functional block is take too much time to execute the WDT timer reset the program considering the programmer logic that this functional block will executed within the less amount of time that the WDT timer  register needs to fill up.


Reset Micro controller :
Reset Mechanism is a built in mechanism for the micro controller. It is used to start the program from the beginning and initialized all the components of the microcontroller such as stack , program counter.
Reset mechanism can be defined by the device module.
Most common reset mechanism is given as follows :

1. Reset during power on (POR).
2. !MCLR reset during normal operation.
3. Reset during SLEEP mode.
4. Watchdog timer reset (WDT).
5. Brown-out reset (BOR).
6. Stack full reset
7. Stack Underflow reset  
  • Reset During  Power On

When ever the device is power on and the supply voltage reaches a certain level an power on reset is occurred.
An external POR reset circuit may be need depends on device design. According to microchip
“ External Power-on Reset circuit is required only if the VDD power-up slope is too slow. The diode D helps discharge the capacitor quickly when VDD powers down ”



  • MASTER CLEAR !MCLR
Fig: !MCLR 
Master clear pin gives a freedom to the user of the device to do forcefully reset during its normal operation. To use this feature an  external push button is associated with that pin of the micro controller. When that push button pin goes low, it reset the micro controller.












No comments:

Post a Comment