1. Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.
    Dismiss Notice

Program to read A/D on firefly...

Discussion in 'Microcontrollers' started by RobertD, Jul 1, 2008.

  1. futz

    futz Active Member

    Joined:
    Sep 15, 2007
    Messages:
    2,043
    Likes:
    24
    Location:
    Vancouver, B.C.
    Here's the same code with 8MHz clock for better debugging speed. It has been tested and works perfect.
    Code (text):
        LIST    p=16F88
        include "P16F88.inc"
        __config _CONFIG1, _WDT_OFF & _INTRC_IO & _MCLR_ON & _LVP_OFF
        ERRORLEVEL 0, -302

        cblock  0x20
        count
        endc

        banksel TRISA       ;bank 1
        movlw   0x70        ;8MHz clock
        movwf   OSCCON
        movlw   B'00000010'
        movwf   TRISA       ;all outputs except RA1
        movwf   ANSEL
        movlw   b'11000000'
        movwf   ADCON1
        banksel PORTA       ;bank 0
        movlw   B'01001001'
        movwf   ADCON0      ; channel 0, FOSC/8, enable A/D
        bsf STATUS,RP0
        movlw   0x70
        movwf   OSCCON
        bcf STATUS,RP0
    bleh    movlw   0x06
        movwf   count       ;initialize count
    loop    decfsz  count,F
        goto    loop        ;until finished
        bsf     ADCON0,GO   ;initiate conversion
    test    btfsc   ADCON0,GO   ;conversion done?
        goto    test        ;not finished
        goto    bleh
        end
     
    Last edited: Jul 3, 2008
  2. AtomSoft

    AtomSoft Well-Known Member

    Joined:
    Feb 7, 2008
    Messages:
    5,670
    Likes:
    41
    Location:
    Brooklyn, NY US
    good luck drawing something in photoshop with the keyboard lol :D
     
  3. futz

    futz Active Member

    Joined:
    Sep 15, 2007
    Messages:
    2,043
    Likes:
    24
    Location:
    Vancouver, B.C.
    Heh. :D Ya. I use Gimp, but same thing. I just keep the mousing to a minimum. I hate pain. Pain hurts me!
     
  4. dave

    Dave New Member

    Joined:
    Jan 12, 1997
    Messages:
    -
    Likes:
    0


     
  5. RobertD

    RobertD New Member

    Joined:
    May 20, 2008
    Messages:
    216
    Likes:
    1
    Location:
    Brampton Ontario

    That's great. I saved the program, and I'll try it tomorrow night. Junebug is powering the firefly, so yellow should be on. The red LED means bad connection, so I unplug and reboot the system. Maybe that's why it's hanging. It was on nearly all the time, I'll have to watch for that.

    I hope it's as simple as that.
     
  6. futz

    futz Active Member

    Joined:
    Sep 15, 2007
    Messages:
    2,043
    Likes:
    24
    Location:
    Vancouver, B.C.
    That's the way it "should" be, but there's an error on the Junebug boards. When Junebug is powering the target yellow is off. Backwards from the real PICkit 2.
     
  7. Pommie

    Pommie Well-Known Member Most Helpful Member

    Joined:
    Mar 18, 2005
    Messages:
    10,158
    Likes:
    339
    Location:
    Brisbane Australia
    ONLINE
    My yellow LED is permanently on as I don't have the BS250 installed.

    Mike.
     
  8. futz

    futz Active Member

    Joined:
    Sep 15, 2007
    Messages:
    2,043
    Likes:
    24
    Location:
    Vancouver, B.C.
    That'll do it. :) But Robert bought his Firefly pre-assembled.
     
  9. blueroomelectronics

    blueroomelectronics Well-Known Member

    Joined:
    Jan 21, 2007
    Messages:
    12,536
    Likes:
    170
    Location:
    Toronto, Canada
    Red means busy, Yellow is reversed On = no target power, Off = target +5V
     
  10. futz

    futz Active Member

    Joined:
    Sep 15, 2007
    Messages:
    2,043
    Likes:
    24
    Location:
    Vancouver, B.C.
    In my experience, more often than not red means the PICkit 2 (Junebug) is cacked. :D:D:D Time to pull the USB and plug it back in. It doesn't happen a whole lot, but more often than it should.
     
  11. RobertD

    RobertD New Member

    Joined:
    May 20, 2008
    Messages:
    216
    Likes:
    1
    Location:
    Brampton Ontario
    Yes more experimentation to do yet. I get the feeling when I'm through with this project, I'll be a lot more knowledgeable about a whole lot of things.... But I won't stop until I have this thing up and running, and I will find out what the problem is.

    I just got home from work, and first thing is to read my email and start MPLAB. As you might have noticed, I am sleep disfuntional, I sleep in spurts, two to four hours at the time. I often have time during the day to catch cat naps, and that only ascerbates the problem.

    Nevertheless, back to PICking at my problem. Or should I say pecking at it... :)

    Well, as soon as I plug it in, the red light goes on. I tried plugging and unplugging, the red light is on all the time. Red and yellow LEDs on all the time.
     
    Last edited: Jul 4, 2008
  12. RobertD

    RobertD New Member

    Joined:
    May 20, 2008
    Messages:
    216
    Likes:
    1
    Location:
    Brampton Ontario
    Looks like I found what the problem is... :)
     
  13. futz

    futz Active Member

    Joined:
    Sep 15, 2007
    Messages:
    2,043
    Likes:
    24
    Location:
    Vancouver, B.C.
    I don't know if this is related, but it's worth a try. Go to the Debugger or Programmer menu (whichever you're set up to use at the moment) and hit "Download OS". That will download and reinstall the firmware in the PICkit 2/Junebug. Might fix that red light.

    Also, before trying the above, try another USB port on the computer. If you have one kicking around, try a different USB cable too. Probably not it, but ya never know.
     
    Last edited: Jul 4, 2008
  14. RobertD

    RobertD New Member

    Joined:
    May 20, 2008
    Messages:
    216
    Likes:
    1
    Location:
    Brampton Ontario
    Did that. Downloaded OS, and changed USB port. Only have one cable, so can't do that. Red LED still on. The LED's have been acting up, sometimes the 12 LEDs on firefly would light up when I loaded the program, sometimes they did not.

    Bill will have a look at it on Saturday, lucky me, I have the master himself to go to in times of trouble. :)
     
  15. blueroomelectronics

    blueroomelectronics Well-Known Member

    Joined:
    Jan 21, 2007
    Messages:
    12,536
    Likes:
    170
    Location:
    Toronto, Canada
    The PICkit2 seems to hate some Intel USB chipsets like the ones in my notebook. (Uses an Intel 82801FB/FBM USB chipset) I use a CF card to USB2.0 adapter and the problem went away.
     
  16. futz

    futz Active Member

    Joined:
    Sep 15, 2007
    Messages:
    2,043
    Likes:
    24
    Location:
    Vancouver, B.C.
    You got a Firefly with twelve LEDs?!?! Lucky dog! Mine only has three! Well, four I guess, but I don't count that one.
     
    Last edited: Jul 4, 2008
  17. RobertD

    RobertD New Member

    Joined:
    May 20, 2008
    Messages:
    216
    Likes:
    1
    Location:
    Brampton Ontario
    12 should be 1-2.... sorry didn't mean to confuse you... :)


    I have a compaq 900mhz, almost as good as a doorstop. But I fine tune it by running it lean and it goes reasonably fast. But it's time to upgrade, and I do want a laptop so I can work while I'm sitting in my truck waiting to get loaded or unloaded. I have plenty of time to use, so a laptop is my next computer, they're cheap nowadays, $600 will get you an Acer. I just don't like Vista at all, don't like the looks of it, and don't like the feel of it, and don't like what I hear about it.
     
    Last edited: Jul 4, 2008
  18. futz

    futz Active Member

    Joined:
    Sep 15, 2007
    Messages:
    2,043
    Likes:
    24
    Location:
    Vancouver, B.C.
    Boat anchor!
     
  19. AtomSoft

    AtomSoft Well-Known Member

    Joined:
    Feb 7, 2008
    Messages:
    5,670
    Likes:
    41
    Location:
    Brooklyn, NY US
    IMHO VISTA SUX! I Sort of like the look of it but the feel and running and asking and asking and did i say asking ? lol its a pain in the booty.If you get a laptop i would recommend getting something downgradable because some newer laptops come with a vista only supported drivers like the mouse wont work on normal xp and stuff ... its sux. Good luck and remember :D Don't Click and Drive!
     
  20. blueroomelectronics

    blueroomelectronics Well-Known Member

    Joined:
    Jan 21, 2007
    Messages:
    12,536
    Likes:
    170
    Location:
    Toronto, Canada
    Yea Vista blows monkey chunks. Who needs it?
     
  21. RobertD

    RobertD New Member

    Joined:
    May 20, 2008
    Messages:
    216
    Likes:
    1
    Location:
    Brampton Ontario
    Vista just gives me a good reason to switch to Linux... I just might try switching over on my compaq once i have another.
     

Share This Page