PROGRAMMING

Programming
If you are new in microcontroller there a lot of question in your mind such as what kind of compiler can i use? where can i refer, to learn the source codes? i'm quite confuse with compilers?..because they are many types of compiler, which progammer should you use and more.

Today I will discuss about microchip. There are several compliers on the market for example, in basic language PICBasicPro Complier, in C language  CSS PICC and the most popular and officialy produce by Microchip is MPLAB. MPLAB Integrated Development Environment (IDE) is a free, integrated toolset for the development of embedded applications employing Microchip's PIC® and dsPIC® microcontrollers. In this short tuturial I will show you how to program in BASIC (mbasic).
Before we start a programming I personally higly recomended you have a datasheet of pic16f84a.



This is my picmicro 16f84a microchip which help me a lot in field of study microcontroller at school. This chip come from long story of 90's older brother 16c84 before. This little pic had been mis-wired, mis-programmed, mis-polarity and so many punishment in early stage of making homemade programmer and development tools. But he survive and still can be programmed until now.




Above is the hard copy of pic16f628 data sheet. New family device such as pic16f1xxx come with 400 to 500 pages datasheet. No kidding you will empty any full bubble jet cartridge ink just for one copy of datasheet. (from my experience)

BASIC programming language are highly recommend for complete beginner.
'''''''''''''''''''''''''''''''''''''''''''''''''
program ledblink
main:
  TRISA = 0x00       ' set direction to be output
  While TRUE
    PORTA.1 = 0     ' Turn OFF diodes on PORTA Pin RA1
    Delay_ms(200)   ' 0.2 second delay
    PORTA.1 = 1     ' Turn ON diodes on PORTA PIN RA1
    Delay_ms(800)   ' 0.8 second delay
  wend               ' Endless loop
end.
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''


Code below show you the same project code using assembly

flash
movlw  1<<gp1 ; turn led on
movwf  porta
movewf .20    ;delay .2second
call   delay10
clrf   porta
movlw  .80
call   delay10
goto   flash


This code will make portA.1 on pic16f84a blinking On and Off in one second delay. Microcontrollers have traditionally been programmed using the assembly language of the target device. Although the assembly language is fast, it has several disadvantages. An assembly program consists of mnemonics, which makes learning and maintaining a program written using the assembly language difficult. Also, microcontrollers manufactured by different firms have different assembly languages, so the user must learn a new language with every new microcontroller


The picture below show you my first homemade working pic programmer base on David Tait shcematic. This is my own version of the classic PIC 16C84/16F84 programmer. The design is originally by David Tait.


This programmer help me a lot in pic programming 12 to 15 years ago i think. Do not misunderstand of poor built quality.He serve me a decade before i got a real programmer. Personally I have built about 4-5 type parallel and serial programmer before but end up with long boring night with not working undetectable faulty circuit.



Picture below show another third party of pic programmer. quite easy to use using USB cable.

If you are true beginner in electronic never made your own programmer. Unless you have nothing to do in your life. Most of DIY PIC programmer circuit available today was design more than 15 years ago. No one will guaranty they still work in new advance OS system and multicore cpu available today. Don't waste your money and time. There are Dozen of company produce a ready to use USB programmer available on the net. just Google it.