Tuesday, 13 September 2011

Mari belajar PIC

Salam,
kepada yang baru dan ingin menambah pengetahuan tentang PIC, sila lah baca. semoga mendapat manfaat

**********
PIC is the name for the Microchip microcontroller (MCU) family, consisting of a microprocessor, I/O ports, timer(s) and other internal, integrated hardware. The main advantages of using the PIC are low external part count, a wide range of chip sizes (now from 5-pin up!) available, nice choice of compilers (assembly, C, BASIC, etc.) good wealth of example/tutorial source code and easy programming. Once bought, the PIC's program memory is empty, and needs to be programmed with code (usually HEX files) to be usable in a circuit.

  • pcbheaven has a great tutorial for beginners in PIC programming.
  • Mikroelektronika PIC Microcontrollers online book is another good source for starting
  • For code snippets and ideas check The PIClist web page and mailing list archives.

FAQ

Q: What can I do with the assembly source code for the PIC microcontroller?

A: First, you need a compiler, which takes the source code in the form of asm (assembly), inc (include), and lkr (linker script) files. You can compile microchip assembly files with gputils or mpasm, part of MPLAB.
(Gputils are command line utilities, mplab is a graphical development environment)

The compiler will output a hex file, suitable for programming into the device. You need a programmer device for that. It is an interface between the computer and the microcontroller. I recommend using the Pickit 2 or 3 this purpose.

Please read the pcbheaven pic pages to get started with compiling code and programming the PIC microcontrollers.

Q: How do I compile a HEX file from multiple source files (linked project or relocatable code) ?
Start MPLAB, and select project/project wizard. Choose the target microcontroller you see in the circuit diagram (for example, PIC16F628). Choose the MPASM toolsuite. Add all assembly (*.asm), header (*.inc) files and the linker script (*.lkr) to the project. Select project/build all. If asked, choose generating "relocatable code", and not "absolute code".

Explanation: There are two incompatible source types for one-file absolute and multiple-file linked projects, you can't write code working for both types. If you want to build modular code which can be combined with other libraries, code must be written in the linkable format, even if it is the only source file in the beginning. But linkable format source must be compiled differently, in two steps: first compiled into an intermediate object format, then linked into a HEX file.  

Q: Where is all this assembly language documented?

A:You can find the PIC microcontroller instruction set documentation in the microcontroller datasheets at microchip.com. The PIC12, PIC16, PIC18, PIC24, PIC32 families of microcontrollers have different instruction sets. In addition, the general syntax of the code (labels, variables, macros, etc.) is described in the mpasm documentation.
**********
source : http://jap.hu/electronic/pic.html

No comments:

Post a Comment