12 August 2007

PIC microcontroler : Day 1

Day 1
So Here our journey is starting.
I assumes that you should have some knowledge of programing , micro-controller and digital electronics and how to turn on a computer. We are going to use PIC mico-controller (these are microchip company product). We will start form very small device. PIC10F2xx series where xx can be 00, 02, 04, 08, 20, 24.
This is a 6 pin IC (in PDIP package 2 pins are not connected)

You must go through the data-sheet of PIC10F200. you can get functionality of pin also in datasheet.
The software tool we are going to use is piklab. you can easily install in Linux by any package manager. In windows you can use MPLAB IDE. ya we will use MPLAB assembler also. see step
  • first you need to write a code in assembly language. We can latter use C language also. I have found a very good tutorial on assembly. 1 . Assembly language 2. MPASM assembler , MPLINK object linker , MPLIB object librarian USER GUIDE
  • you need to convert your asm code to hex file using MPASM or gpasm depending on plateform
  • you need to download you hex code to flash memory of micro-controller (mcu). you need to have a programmer for it and a software to drive it, we will discuss it latter. for the timing I will use software simulator for it.
Before we start programming we need to look inside it. our mcu has some 16/24 Byte data memory and 256/512 flash memory.

have you remembered about registers in processors. well our PIC10F22x has some limited register set. these register are present on data memory.
pattern of data memory or more precisely register file map is given in data sheet page 17. We have two set.
1. special function (named) regiter
2. general purpose register

in special you can see STATUS which hold many status of accumulator and various thing,
you can see GPIO register. whenever you need to put data or read data to GPIO pins (general purpose input out pins), you need to access this register. now in our devide we have only 4 GPIO. GP0, GP1 and GP2 are bidirectional and their direction must be set before using them, GP3 is in input pin only. TRISGPIO is a register which set the direction, We will not jump in to every details of everything. slowly slowly we expand our knowledge by programming exercises also.

in PIC10F200/204 have 9 bit memory address but 512x12 memory is not there for you, you can access first upper 256x12 memory only. simply for now forget about 9th bit.
in PIC10F202/206 have 10 bit memory address but 1024x12 memory is not there for you, you can access first upper 512x12 memory only. simply for now forget about 10th bit.

No comments: