Profanity applicable.

Discussion in 'Embedded Systems and Microcontrollers' started by Dragonblight, Aug 19, 2009.

  1. Dragonblight

    Thread Starter Active Member

    Aug 19, 2009
    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-

    Code ( (Unknown Language)):
    2. #include <>        
    4. COUNT1    equ    0x10
    5. COUNT2    equ 0x11    
    6. GPIO    equ    0x06
    9. org 0x0000
    11. movlw    0x00
    12. tris    6
    15. START    movlw    0xff
    16.         movwf    GPIO
    17.         call    DELAY
    18.         movlw    0x00'
    19.         movwf    GPIO
    20.         call    DELAY
    21.         goto    START
    25. DELAY
    26.         movlw    0xfa
    27.         movwf    COUNT2
    29. DELAY_0    movlw    0xfa
    30.         movwf    COUNT1
    32. DELAY_1    decfsz    COUNT1
    33.         goto     DELAY_1
    35.         decfsz    COUNT2
    36.         goto    DELAY_0
    38.     retlw 0x00
    41. 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.)
  2. HarveyH42

    Active Member

    Jul 22, 2007
    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...

    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: Aug 20, 2009
  3. rjenkins

    AAC Fanatic!

    Nov 6, 2005
    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.
  4. Dragonblight

    Thread Starter Active Member

    Aug 19, 2009
    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: Aug 21, 2009
  5. rjenkins

    AAC Fanatic!

    Nov 6, 2005
    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.