can't even flash an LED


Closed Thread
Results 1 to 8 of 8
  1. #1
    bruno333's Avatar
    bruno333 Guest

    Default can't even flash an LED

    Warning this is an extreme newbie post! I'm just migrating over from Basic Stamps.

    Anyway, I'm using PBP with Microchips Pickit USB programmer. 12F675 processor. I'm trying to flash individual LED's on the board with the following very simple program. The strange results are commented below. Anyone have ideas on what I might be doing wrong?

    John

    ' Flash LED (Sample 1)
    '
    ' Blinks LED using HIGH and LOW commands to control specified pin.

    CMCON = 7 ' Comparators OFF
    ANSEL = 0 ' A/D OFF -- Port pins all digital
    TRISIO = %010000 ' All I/O but GPIO3 = outputs
    GPIO = %000000 ' All 0 on boot


    Symbol LED = 4 ' LED Pin

    Loop: High LED ' LED On
    Pause 3000 ' Delay 1/2 Second
    Low LED ' LED Off
    Pause 3000 ' Delay 1/2 Second
    goto Loop ' Forever

    ' LED = 1 flashes D7 on Pickit 1 board
    ' LED = 4 flashes D2 and D0 on Pickit 1 board
    ' LED = 5 flashes D4 on Pickit 1 board
    ' LED = 0 flashes nothing on Pickit 1 board
    ' LED = 2 flashes D5 and D6 on Pickit 1 board
    ' LED = 3 flashes nothing on Pickit 1 board

  2. #2
    Join Date
    Dec 2003
    Location
    Wichita KS
    Posts
    511


    Did you find this post helpful? Yes | No

    Default

    Hello John,

    JOhn>>
    CMCON = 7 ' Comparators OFF
    ANSEL = 0 ' A/D OFF -- Port pins all digital
    TRISIO = %00001000 ' All I/O but GPIO3 = outputs

    I added 2 zeros to your TRISIO, and changed the position of your GPIO.3 switch



    Loop:

    High GPIO.2

    Pause 500

    Low GPIO.2

    Pause 500

    goto Loop

    end.


    I could not check this out, because I am at work, but this should be very close to what you are looking for.

    DWayne
    Ability to Fly:
    Hurling yourself towards the ground, and missing.

    Engineers that Contribute to flying:
    Both optimists and pessimists contribute to the society. The optimist invents the aeroplane, the pessimist the parachute

    Pilots that are Flying:
    Those who know their limitations, and respect the green side of the grass...

  3. #3
    bruno333's Avatar
    bruno333 Guest


    Did you find this post helpful? Yes | No

    Default re: can't blink an LED

    Thanks for your help. I tried the code below, and it now flashes D2, D4, and D7 on the Pickit 1 board simultaneously. This thing is driving me nuts! Certainly you can symbol a specific output right?


    CMCON = 7 ' Comparators OFF
    ANSEL = 0 ' A/D OFF -- Port pins all digital
    TRISIO = %00001000 ' All I/O but GPIO3 = outputs


    Loop: High GPIO.2 ' LED On
    Pause 3000 ' Delay 1/2 Second
    Low GPIO.2 LED Off
    Pause 3000 ' Delay 1/2 Second
    goto Loop ' Forever

  4. #4
    Join Date
    Dec 2003
    Location
    Wichita KS
    Posts
    511


    Did you find this post helpful? Yes | No

    Default

    Hello Bruno333,

    B>>Certainly you can symbol a specific output right?<<

    Yes, you can. But I wanted to give you the simplist of code to start out with.

    LEDPin var GPIO.2

    Loop:
    High LEDPin
    pause 500
    Low LEDPin
    Pause 500
    goto Loop
    end


    Dwayne
    Last edited by Dwayne; - 27th April 2005 at 23:11.
    Ability to Fly:
    Hurling yourself towards the ground, and missing.

    Engineers that Contribute to flying:
    Both optimists and pessimists contribute to the society. The optimist invents the aeroplane, the pessimist the parachute

    Pilots that are Flying:
    Those who know their limitations, and respect the green side of the grass...

  5. #5
    Join Date
    Jul 2003
    Posts
    2,405


    Did you find this post helpful? Yes | No

    Default

    FYI TRIS statements are not necessary when you're using the PBP HIGH & LOW commands. PBP *automatically* sets the pin up as an output.

    If you use GPIO.2 = 1 or 0, then you'll need to first set the TRIS register to make this bit an output. If you use HIGH or LOW GPIO.2, then PBP sets GPIO.2 up as an output automatically.

    Why the PicKit board gives you odd results is due to the way the LED's are wired on the board. Look for the PicKit board schematic or download it here http://ww1.microchip.com/downloads/e...Doc/40051D.pdf

    Here's a simple BASIC example that strobes LED's D0 to D7 on the PicKit 1 board.
    Code:
    @ DEVICE PIC12F675, INTRC_OSC, WDT_OFF, MCLR_OFF
    Define	OSCCAL_1K	1	' Calibrate internal oscillator
    
    CMCON = 7 ' Comparators OFF 
    ANSEL = 0 ' A/D OFF 
    
    ' Modified from Microchip PicKit 1 state.asm demo source
    D0_D1	CON %00001111	; TRISIO setting for D0 and D1
    D2_D3	CON %00101011	; TRISIO setting for D2 and D3
    D4_D5	CON %00011011	; TRISIO setting for D4 and D5
    D6_D7	CON %00111001	; TRISIO setting for D6 and D7
    
    '; define LED state (what GPIO will equal)
    D0_ON	CON %00010000		; D0 LED
    D1_ON	CON %00100000		; D1 LED
    D2_ON	CON %00010000		; D2 LED
    D3_ON	CON %00000100		; D3 LED
    D4_ON	CON %00100000		; D4 LED
    D5_ON	CON %00000100		; D5 LED
    D6_ON	CON %00000100		; D6 LED
    D7_ON	CON %00000010	 	; D7 LED
    
    TIME VAR BYTE
    
    Main:
        FOR TIME = 50 TO 200 STEP 25
    
            TRISIO = D0_D1 : GPIO = D0_ON
            PAUSE TIME : GPIO = D1_ON
            PAUSE TIME
    
            TRISIO = D2_D3 : GPIO = D2_ON
            PAUSE TIME : GPIO = D3_ON
            PAUSE TIME
    
            TRISIO = D4_D5 : GPIO = D4_ON
            PAUSE TIME : GPIO = D5_ON
            PAUSE TIME
    
            TRISIO = D6_D7 : GPIO = D6_ON
            PAUSE TIME : GPIO = D7_ON
            PAUSE TIME
    
        NEXT TIME
        GOTO Main
    Last edited by Bruce; - 28th April 2005 at 06:26.
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

  6. #6
    bruno333's Avatar
    bruno333 Guest


    Did you find this post helpful? Yes | No

    Default

    Yeah, I just figured out the LED wiring of the Pickit a few minutes ago before I read your post. Very strange way to do things? I've used several development boards, and usually LED's are wired individually to the separate pins so you can quickly (and simply) check program operation. Why on earth did they do it this way? The LED's are wired with several forward and other's reverse polarity. Sure I guess you might want to experiment with Hi and low outputs... but geeze what a mess.

    Besides that, it's a nice programmer. No wall-wart, and 36 bucks.

  7. #7
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    hehe that's what i often call an engineer trip. Bah that's doing food for your brain cells.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  8. #8
    Join Date
    Jul 2003
    Posts
    2,405


    Did you find this post helpful? Yes | No

    Default

    I think the idea was to show creative appplication of limited resource devices like the 8 & 14-pin targets. It is a nifty board considering the investment.
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

Similar Threads

  1. new and need help
    By smeghead in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 3rd November 2008, 21:19
  2. LCD will not start
    By btaylor in forum mel PIC BASIC Pro
    Replies: 49
    Last Post: - 24th May 2007, 03:30
  3. I can't even make an LED flash!
    By George in forum mel PIC BASIC Pro
    Replies: 12
    Last Post: - 3rd April 2007, 07:39
  4. Need help with write function
    By Christopher4187 in forum General
    Replies: 10
    Last Post: - 12th July 2006, 05:12
  5. elapsed time between two led flash...
    By dario in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 5th February 2006, 17:09

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts