Profanity applicable.

Thread Starter

Dragonblight

Joined Aug 19, 2009
35
So, i've been putzing with PICs for two weeks, but I tell you what, it's the darndest thing, I CAN'T GET THE STUFFE TO WORK.

Now, i'm no newb, and i'm no idjiot, but this here shennanigans is getting frustrating all up on my nerves.

I've tried with a pic 16f506, a 10f200 and a 10f220 (I think I blew up a 10f220- it was totally interesting and has been logged in the name of science) with varying codes and what not, but this is what i've got-

Rich (BB code):
#include <p10f220.inc>         

COUNT1    equ    0x10
COUNT2    equ 0x11    
GPIO    equ    0x06
__CONFIG (_MCLRE_OFF & _CP_OFF & _WDT_OFF & _MCPU_OFF & _IOFSCS_4MHZ)

org 0x0000

movlw    0x00
tris    6


START    movlw    0xff
        movwf    GPIO
        call    DELAY
        movlw    0x00'
        movwf    GPIO
        call    DELAY
        goto    START
    


DELAY
        movlw    0xfa
        movwf    COUNT2
        
DELAY_0    movlw    0xfa
        movwf    COUNT1
        
DELAY_1    decfsz    COUNT1
        goto     DELAY_1

        decfsz    COUNT2
        goto    DELAY_0

    retlw 0x00


END
Yes, it's simple, it's great, and I hate it. I don't want to hate it but it doesn't work.

After successfully connecting this code to my PICKIT 2(tm) with verifications and everything, I plug it into my breadboard. I have a GND rail and +5v rail going on, connected directly to Vdd and Vss. From a few of the output pins (if you can tell by the code- what output pin is almost completely a moot point) is an led (correctly polarized) and a 1k resistor plugged right to the GND rail.





Now, how am I jacking this up?



(P.S. is profanity frowned upon here? It's second nature for me to drop f-bombs.)
 

HarveyH42

Joined Jul 22, 2007
426
Try Nigel's tutorials, best on the web. I chose AVR, to avoid your sorrows, so not too familiar with your code, but don't you have to do something with the port pins? So much code, to just flash an LED, but don't see anything to change the pins output. Think you also need to set the pins to output.

Anyway, I don't use PIC, but Nigel's tutorials got me up and running on AVR in under an hour, so they must be awesome for the intended PICs.

Oops, wrong electronics forum...
http://www.winpicprog.co.uk/pic_tutorial.htm

This guy is a moderator on another electronics site (just visited), similar to this one, a little early in the morning for me...
 
Last edited:

rjenkins

Joined Nov 6, 2005
1,013
Hi,
I'd first check the I/O pin you are using and the value written to the TRIS register, to ensure the pin you have the LED on is actually set as an output.

You dont mention that the LED does anything, and from your description you have an IO pin to LED anode then LED cathode to 0V via 1K.

For that to turn on, it only needs the first four instructions:
movlw 0x00
tris 6
START movlw 0xff
movwf GPIO

It's a long time since I've used anything other than 18F & DSPIC devices so the details are a bit fuzzy, but I believe the Pickit2 will also operate in debug mode if the device supports it (or you have the appropriate debug header with the special version debug device).

Even without that, MPLab supports software emulators. If you enable the Register view you should be able to single-step your program and check what values are actually written to the TRIS & Port registers, & hopefully work out what is going on in the PIC.
 

Thread Starter

Dragonblight

Joined Aug 19, 2009
35
Hey man, huge thank you for the heads up on the simulator, it's really helped me along the way, it turns out I may very well have mental issues and should have asked for some help sooner.

You sir, are a scholar and a gentleman.



Still not working- but it's mountains closer



I'm just trying to get the LEDs to blink.


While the internet tutorials are handy, I totally grasped assembly coding (and that puts me further ahead of my peers- the putzes they are) and interfacing (even further) but it turns out I never took the time to understand properly building the code. I've just been using export as hex and then using the pickit2 software to upload it.

Hat's off to you!

Re-edit: It works.
 
Last edited:

rjenkins

Joined Nov 6, 2005
1,013
Glad to hear you got it going!

I've not got the PicKit2 (I use ICD2) but from what I've read it works almost exactly the same.

You can configure it either as a debugger or programmer *within MPLab*, and (if the chip or header supports it) have it connected to your prototype setup and monitor / single step the program in your actual harware.

This makes testing and development infinitely easier than having to keep pulling the chip, programming it then another 'does it work?' test..

A lot of the newer PICs support this directly, all you need is a connector tagged on to the appropriate three pins & 5V power.
 
Top