[ ssonezc @ 09.01.2006. 09:14 ] @
Da li neko moze da mi pomogne.treba mi uputstvo kako programirati Pic mikrokontrolere.treba mi bilo kakvo uputstvo ili neki link na koji mogu da nadjem..

Unapred hvala..
[ chupcko @ 09.01.2006. 10:22 ] @
Pa ima jedno 100 nacina za programiranje :), da li pitas kako pisati programe za pic ili kako vec napisan i hexovan program prbaciti na pic ?

Ali evo linka :)
http://en.wikipedia.org/wiki/PIC_microcontroller
[ ssonezc @ 09.01.2006. 11:26 ] @
Da nisam bio dovoljno precizan.Mislio sam kako da napisem program.hvala za link pogledacu.

Pozdrav..
[ samotako @ 09.01.2006. 12:23 ] @
Evo jednog teksta sa drugog foruma koji je meni pomogao dosta... inace i ja sam pocetnik.

Pozdrav,

Milan

Everytime somebody new comes to this discusion forum, he/she asks the same questions about PICs. This post is intended for answering such questions.

Most of the answers are in the Datasheet read it carefully!

1. Which PIC to choose?
Many would say 16F84, but please keep in mind that this PIC is old and expensive, so don't use it for new design, unless you have hundrets of them. If you are new to PICs, you'd probably take 16F628A. There are many tutorials and schematics that use it.
16F628A-18Pin, Flash based,Internal Oscilator, PWM module, ICSP, USART
If you are looking for bigger PICs, try 16F876-28 pin and 16F877-40pin.
Also small PIN count PIC: 12F675-8pin or 10F206-6pin!
Later you may want to advance to 18F PIC series, which are called "High End", because they are more powerfull and have better support for higher level languages (mostly C optimised). Just for information, there is also a DsPIC series from Microchip, which offer 16-bit core and DSP capabilities and with clock frequency up to 160Mhz brings you absolute top power solution... These CPU's are really powerfull. (But absolutelly not appropriate for beginners )

2. Where to find tutorials?
Try Nigel Goodwins tutorials (they use 16F628,876 & 877)
PIC programmer software, and PIC Tutorials at:
http://www.winpicprog.co.uk

And some other that include tutorials & projects:
http://www.mikroelektronika.co...duct/books/PICbook/picbook.htm
http://www.mstracey.btinternet.co.uk/pictutorial/picmain.htm
http://www.pages.drexel.edu/~k...s/PICTutorial/PICTutorial.html
http://www.to-pic.com/
http://www.devrs.com/pic/
http://www.rentron.com/pic.htm
http://tutor.al-williams.com/
http://www.pic-c.com/links/books.html
http://www.towertech.it/personal/azummo/
http://www.piclist.com/techref/piclist/index.htm
http://www.dontronics.com/piclinks.html
http://ee.cleversoul.com/pic.html
http://www.sparkfun.com/shop/i...mp;cart=324125&cat=52&
http://www.boondog.com/tutorials/pic16f84/pic16f84.html
http://www.voti.nl/swp/
http://www.botkin.org/dale/pic_tutorial.htm
http://www.programmersheaven.com/zone5/cat197/index.htm
http://www.siriusmicro.com/projects.html
http://members.vol.at/home.floery/electronix/picnic/

Other stuff
http://www.gnupic.org/

One of these projects was posted here a while ago, but this guy simply comes up with such incredibly useful ideas that I had to post this :
http://members.cox.net/berniekm/

3. What programming Software + HW should I use?
a) Download MPLAB (Developing enviroment) from www.Microchip.com
b) Download Ic-Prog (Programming software) www.IC-Prog.com
c) Programmer schemes :
JDM: www.jdm.homepage.dk/newpic.htm
RCD: http://osaka.cool.ne.jp/feng3/en/rcd.html
Paralel: http://www.bobblick.com/techref/projects/picprog/picprog.html
Or try Nigels page...
d) Linux is also supported, check this out
e) After you have learned the Basics of PIC, I highly recomend you to build yourself (or buy original) ICD2 - In Circuit Debugger 2. It's a nice tool from Microchip, which acts as Universal PIC programmer (uses MPLAB directly) and as PIC Debugger. Debugger feature allows you to run/step program inside PIC and even set breakpoints and directly read/write all registers status! More info at www.stolz.de.be

4. Which Programming language to choose?
a) If you are starting with PICs, I strongly recomend learning Asembly first. Most programs on Internet are written in it. Also keep in mind that Asembly is code compact and fast. Microchips Aplication Notes are also written in it.
b) If you know Asembly well, You might try C based programming languages. C will simplify your program (but will take more resources). Many complex projects are made in C (mostly 18F based, but also available for 12F/16F).
c) Or try Basic, If you know PC BASIC this is really simmilar: http://www.mikroelektronika.co...compilers/mikrobasic/index.htm

5. Some of my output PINs are not working!
This is a common problem. Usually people try to put LOG.1 to PINs which are only inputs (aka PORTA,5 or PORTE,3 are usually Input only), Or you are trying to put 5V to PIN which can only output GND. Such PIN is called "Open Collector Output". Such PIN is "missing" a Transistor from VDD to PIN, thefore PIN can't go HIGH. And ofcourse the NPN transistor which is there connecting PIN to VSS can't output LOG.1 But only LOG.0 If you want to use is as general TTL compatible output, just add Pull-up resistor from that PIN to +5V (4K7 is enaugh). But keep in mind this LOG.1 wont be "strong" enaugh to drive LEDs! (If you want to drive LED's with it, connect anode of LED to +5V and Cathode to PIN, this will allow you to turn on the LED by putting LOG.0 on the output PIN, be sure to use a suitable current limiting resistor in series with the LED.)
Beginners usually don't like Open Collector PINs, but they will find it useful latter, when they advance into "self-designing" level.

Make sure that any internal PERIPHERAL is NOT taking over desired PIN, For example is you activate TIMER1 oscilator or ICD support, you can't use PORTB6,7 for ANY purpose! This applies to both Input and Output problems.
List of peripherals (and features) that may cause problems:
MCLR - may prevent PINs PORTA,5 OR PORTE,3 to be used as general purpose input, disable it by clearing Master Clear Enable bit in configuration register.
Comparator Module - pins PARTA 0-3 are set to Analog mode with comparators enabled by default. Writting a correct value to CMCON register (read Datasheet) will disable them. (Affected devices: 16F628, 16F628A, 16F876A, 16F877A, 16F88, 12F629, 12F675, 12F683... and more)
LVP - this is a special way of programming PIC with only +5V on MCLR and LVP pin PORTB3 or PORTB4 will control if PIC is on normal or in program mode. because this "feature" will block one PIN, I highly recomend to DISABLE it by clearing LVP bit in config register.
ICD support will allow you to debug the PIC, but if you don't use ICD, under no circumstances enable DUBUG bit in config register, this would reserve PORTB6 & PORTB7 pins and your program won't be able to use them.

6. Some of my input PINs are not working!
First check the datasheet if the default state of the PIN is Digital Input, if it says that the Reset state is analog (comparator or ADC), you need to disable analog feature at the beginning of your program. This is a common problem, when you switch from 16F84 to 16F628 without rewriting the program (16F628 has Comparators turned on by default, whereas 16F84 doesn't have them at all). Also if you plan to use PORTA,5 or PORTE,3 as general inputs, you have to disable MCLR function first becasue they share the same PIN.

7. What are Watchdog, CCP, Timer etc ...
Watchdog timer (WDT) is an Independent oscilator+timer, that will reset (or wake-up) the PIC if you don't clear the timer value. This has do be done regulary in your PIC software by calling CLRWDT instruction. Watchdog prevents your program do be locked in loop, because if it would get stuck, the CLRWDT instruction wouldn't get exectued and the PIC will reset and get out from the loop. Or you can use Watchdog to periodicaly wake the PIC up from sleep, and thus it saves one precious Timer (that can be used elsewere). The WDT is a crude RC oscillator, it's accuracy is very poor, and highly dependent on external factors such as temperature. However, this doesn't matter for it's designed purpose as a watchdog.
CCP is a unit that has three functions:
1. In Capture mode, CCPR register captures the 16-bit value of the TMR1 register (Timer1) when an event occurs on pin RB3/CCP1.
2. In Compare mode, the 16-bit CCPR register value is constantly compared against the TMR1 register pair value. When a match occurs, the RB3/CCP1 pin is altered (see datasheet)
3. In Pulse Width Modulation (PWM) mode, the CCP1 pin produces up to a 10-bit resolution PWM output. Since the CCP1 pin is multiplexed with the PORTB data latch, the TRISB<3> bit must be cleared to make the CCP1 pin an output.
Timer unit has to modes of operation:
1. Counter mode, is counting impulses from a dedicated input pin. This can serve also as a debounced input (Timer overflow will indicate that a button was pressed)
2. Timer mode, is counting oscilator pulses (Primary or Secondary), this will allow your program to know how much real time has passed (to construct delays, software serial busses etc)

8. Here you will find sample programs that will help you start.
These programs will Flash LEDs on all their ports, usefull for beginners if they are not sure where is the problem (Programmer, program or MPLAB).

<under construction> looking for a Web Host for Images and Files!

Don't forget to download newest Datasheet for PIC you are working with from www.Microchip.com. Good Luck!
[ ssonezc @ 10.01.2006. 06:34 ] @
Hvala puno prelistacu ...

POZDRAV...