Thứ Ba, 18 tháng 11, 2014

PICKIT2 PROGRAMMER


  • I bought the Pickit2 from Microchip Inc. in 2008 and still using it until now. The PICKit 2 Programmer/ Debugger is a low-cost development tool with high performance and statability, easy to use to program/debug for PIC Microcontrollers (have Flash memory). Moreover, Pickit2 can be used as a Terminal tool that helps to communicate with PC by using its UART Tool và Logic Tool Analyzer function. Pickit2 can use the stand-alone software PICKit 2 or MPLAB IDE.


  • Main features: 
    • The PICkit 2 uses an internal PIC18F2550 with FullSpeed USB. 
    • Programmer, Debugger, UART Tool and logic tool Analyzer.
    • Automatic connect and detect chip. One ore more PICKit 2 can be used in a same PC at a same time.
    • Firmware is updated automatically.
    • The latest is "PICkit 2 Firmware V2.32" and no longer updated by Microchip. (see Pickit 3).
    • Detect and use the external power supply from target Board.
    • "Program To Go" function allows to program the chip without PC.
    • Program and debug most of the 8 and 16 bit PICmicro and dsPIC members of the Microchip product line (view the list).
    • The PICkit 2 is open to the public, including its hardware schematic, firmware source code (in C language) and application programs (in C# language). End users and third parties can easily modify both the hardware and software for enhanced features. e.g. GNU/Linux version of PICKit 2 application software, DOS style CMD support, etc.



  • You can check more detail about documentations, softwares of Pickit2 from Microchip website.
  • Or you can refer to my Pickit2 "clone" version here to make yours.

Thứ Hai, 17 tháng 11, 2014

PIC16F877A I/O PORTs PROGRAMMING

I/O PORT PROGRAMMING IN PIC16F877A
    •  PIC 116F877A has 40 pins, 33 pins are set as 5 Input/Output ports: PORTA, PORTB, PORTC, PORTD and PORTE.
    •  PORTA has 6 pins, PORTB/PORTC/PORTD has 8 bins while PORTE has 3 pins.
    •   Each port of PIC16F877A has some others functions, such as ADC, Interrupts, Timers, Serial Communication…
    •  Each port can be configured as input or output by setting to its corresponding TRIS register.
    • In this article, I will talk about PIC16F877A Digital I/O function first.
PORT AND TRIS REGISTER
    •  The data direction is depended on TRIS register. Each Port has its corresponding TRIS, i.e: PORTA & TRISA, PORTB & TRISB… 
    • Setting an TRIS bit to logic 1 will make the corresponding PORT pin an Input.
    • Setting a TRIS bit to logic 0 will make the corresponding  PORT pin an Output.
    •    Reading the PORT register reads the status of that PORT (pins), whereas writing to it will write to the port latch.
EXAMPLE TO OBSERVE THE STATUS OF OUTPUT PORT.
    •      In this example, we will build a simple circuit to test the output function of PIC16F877A’s PORT. Please refer the following schematic:



    •      Now we set RB0 as an output, then send the logic 1 to turn on the LED and toggle it after every 500ms. The code below is writing in C language. After compiled, we send the Hex file to PIC via ICSP port (by any programmer you have).

    • Turn on/off the LEDs after 500ms:
    • LED "running" effect:
    • Let's combine 3 programs above into one and see the result:



  • For detail description about PIC16F877A’s PORT & TRIS registers, please refer to its datasheet from Microchip webpage:
  • In next articles, we will practice about I/O programming by building more LED flashing programs with PIC MCU and push button..

  • PIC MICROCONTROLLERS' DATASHEETS

    The following Microchip PICs are often used in many projects at University or Labs: