Microchip Pickit 2 with PIC16F887 in Assembly

Thread Starter

MMattar9

Joined Sep 12, 2013
3
Hello,

I have a university project due soon that requires me to count from 0 - 255 in binary. I am completely stuck on this. I know it's fairly simple, just not making much progress. If someone could help me out that would be awesome!

I am using the Pickit 2 from Microchip with PIC16F887.

Here is the data sheet for the chip:
http://ww1.microchip.com/downloads/en/DeviceDoc/41291G.pdf

http://www.microchip.com/wwwproducts/Devices.aspx?dDocName=en026561

Additional information:
http://www.mikroe.com/products/view/11/book-pic-microcontrollers/

Thanks!!
 

tshuck

Joined Oct 18, 2012
3,534
The datasheet has all the information you could want for this task beginning on page 235.

What exactly are you struggling with?
 

tshuck

Joined Oct 18, 2012
3,534
Gotcha...

If you look here, there is a simple program to show the general structure of an assembly program.

I'd recommend going through some of the other tutorials too in order to get the hang of things...
 

MaxHeadRoom

Joined Jul 18, 2013
28,619
+1 on Nigel Goodwin's site.
If this is a one off, you may not be into building the boards, but if so, Futurlec has the strip boards.
http://www.futurlec.com/Protoboards.shtml fairly cheap.
If going on to other projects, I have found the different modules handy for prototyping.
The difference was I found it easier to use double row 20pin ribbon instead of the single row headers.
Max.
 

t06afre

Joined May 11, 2009
5,934
Sound strange to me that you are thrown into such a project just out of the blue. In most university settings if not any. You will always have some course background before a task like this is given to you. You learn the theory first then you get back the lab to use what you have learned.
Regarding the matter on how to start programming that we may help you with. But it would help us (at leat me) if you could give some information. Like will you be using C or Assembler.
 

JohnInTX

Joined Jun 26, 2012
4,787
This describes how to do a quick project in MPLAB 8.x. Use the attached source file in place of the one in the post and specify the 18F887 in place of that PIC. Use MPSIM as the debugger as discussed. Build and open a watch window. Watch 'Count'. Step through to see how it works.

Have fun.
 

Attachments

absf

Joined Dec 29, 2010
1,968
The program only increments a variable called "count". You have to copy the contents of "count" to one of the ports first before it can be displayed in binary form.

I simulated the program on proteus and copy "count" onto "Port D" and use the "7-seg BCD" in the library to display as 2 hex digits from 00-FF. I also added some delays between each display so it wont display too fast

Allen
 

Attachments

Last edited:

ErnieM

Joined Apr 24, 2011
8,377
I simulated the program on proteus and copy "count" onto "Port D" and use the "7-seg BCD" in the library to display as 2 hex digits from 00-FF. I also added some delays between each display so it wont display too fast
The 7 segment display you drew seems to take 4 bits as an input to produce a hex number output. Do you have a part number for this?
 

Art

Joined Sep 10, 2007
806
The OP asked for a counter. Its a counter. I agree its pretty lame as is. A better description of the problem would help from here.
Yes, since counting from 0-255 in binary is a nonsensical objective in the first place.

Nothing wrong or lame with your example at all,
the result just has to be moved to a port of LEDs for every count iteration to display binary.
 
Top