The worst programmer ever to grace this forum - ME!


Closed Thread
Results 1 to 40 of 50

Hybrid View

  1. #1
    Join Date
    Mar 2009
    Posts
    653


    Did you find this post helpful? Yes | No

    Default

    Hey Bruce...that compiled without errors! (which is progress in my books! A big thanks to Joe.S too, as it's pretty much as he said...just naivity wrt commenting out the inc file on my part)

    Can someone explain what's actually going on with the looping part though....

    main:
    portc = 0
    pause 500
    for i = 1 to 15
    portC = i
    pause 150
    next i
    goto main


    It looks like it's setting port C output to be low, waiting 500 (milliseconds?), the making PRT C = i .....what's that "i" melarkey all about?!!


    Still no sign of life from the LED on my PICkit 2 board though (though I'm figuring Port C needs to be set high at some stage ....by the way, why no use of PORTC.0 or PRTC.1 here...ie nominating the actual chip pin RC0, RC1 etc?)

    tks,
    Hank.
    Last edited by HankMcSpank; - 14th March 2009 at 15:06.

  2. #2
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by HankMcSpank View Post

    Can someone explain what's actually going on with the looping part though....

    main:
    portc = 0
    pause 500
    for i = 1 to 15
    portC = i
    pause 150
    next i
    goto main


    It looks like it's setting port C output to be low, waiting 500 (milliseconds?), the making PRT C = i .....what's that "i" melarkey all about?!!


    Still no sign of life from the LED on my PICkit 2 board though (though I'm figuring Port C needs to be set high at some stage ....by the way, why no use of PORTC.0 or PRTC.1 here...ie nominating the actual chip pin RC0, RC1 etc?)

    tks,
    Hank.
    Last things first, The code assumes the port arrangement is from lowest order portc.0 to highest order portc.7 in its display of count. The i is just a name for the variable storing the count, you can rename it HankMcSpank and it will work the same, it is just easier to use i. So you have a variable storing a binary count to 15, the i=i<<1 is there to alter the light sequence so you do not have any dark leds in between lit ones. Try commenting it out and you will see it count in binary. Change the 15 to seven and it will only light 3 LEDs.
    <br> Now as for no signs of life from your LEDs, in the PICkit2 programmer software there is a check box that must be selected to power your demo board, unless you rig a separate power line to it.
    <br>__config MyConfig is a trick I picked up from Darrel so as to avoid having my config statement run off the reservation (the page). This is especially helpful if you print your code for archival purpose. You can, and most do put it all on one line like so:<br>@ __CONFIG _INTRC_OSC_NOCLKOUT & _WDT_OFF & _PWRTE_ON & _MCLRE_ON & _BOR_OFF

    Edit: I initially misunderstood last question.
    Last edited by Archangel; - 14th March 2009 at 19:30.
    If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
    .
    Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
    .
    There simply is no "Happy Spam" If you do it you will disappear from this forum.

  3. #3
    Join Date
    Mar 2009
    Posts
    653


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Joe S. View Post
    <br> Now as for no signs of life from your LEDs, in the PICkit2 programmer software there is a check box that must be selected to power your demo board, unless you rig a separate power line to it.
    VDD *is* present (ie I double checked, by testing the VDD test point with my Voltmeter ....when I added the Pickit 2 to PICBASIC, I quickly established that -T needed to be added to the parameter field to keep VDD on the board when the programming sequence exited.

    My LEDS are doing anying!

    Could you please outline what bit of code would need to follow your 'chaser' to raise all RCx ports high? ...

    @MyConfig = _INTRC_OSC_NOCLKOUT & _WDT_OFF & _PWRTE_ON
    @MyConfig = MyConfig & _MCLRE_ON & _BOR_OFF
    @ __config MyConfig

    DEFINE OSC 4
    PortA = 0
    PortB = 0
    PortC = 0
    TRISA = 0
    TRISB = 0
    TRISC = 0
    i var byte


    ....I'll settle for *any* illuminated LED at this stage! (flashing or not).

    The PICkit 2 board has an LED connected to pins RC0-RC3. (btw: I can handle references like PORTC.0 PORTC.1 ...but at this stage, I'm just not locking in to referencing the Port C pins on the PIC in other ways!)



    PS As a sanity check, I've just programmed up the PIC with the Microchip "rotate" hex code....all LEDs light up & chase just fine.
    Last edited by HankMcSpank; - 14th March 2009 at 20:25.

  4. #4
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    _MCLRE_OFF
    ???
    I do not have the board you have, just maybe..
    Dave
    Always wear safety glasses while programming.

  5. #5
    Join Date
    Mar 2009
    Posts
    653


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by mackrackit View Post
    _MCLRE_OFF
    ???
    I do not have the board you have, just maybe..
    BINGO! That was it!!! Many thanks to you all!!

    For the record, anyone else with a PICkit 2 board (with a PIC16F690) .....to save you hours of puzzlement...

    In your C:\PBP\16F690.INC , comment out this one line (thanks to Bruce)...

    ; __config _INTRC_OSC_NOCLKOUT & _WDT_ON & _MCLRE_OFF & _CP_OFF

    Put all of the following code at the top of your PICBASIC programming window (thanks to mackrackit for the _MCLRE_OFF tip)...

    @MyConfig = _INTRC_OSC_NOCLKOUT & _WDT_OFF & _PWRTE_ON
    @MyConfig = MyConfig & _MCLRE_OFF & _BOR_OFF
    @ __config MyConfig

    DEFINE OSC 4

    i var byte

    ANSEL=0 ' all digital
    ANSELH=0 ' analog module disabled
    CM1CON0=0
    CM2CON0=0
    PortC = 0
    TRISC = 0



    And if you have - like I have - a burning desire to see your board's LEDs light in sequence, add this bit of code (thanks to Joe.S)...

    main:
    portc = 0
    pause 500
    for i = 1 to 15; step -1
    portC = i
    i=i << 1
    pause 250
    next i
    goto main
    end



    What's a beginner to do?!!! Most of this was (is!) double dutch....a what with a day & a half's effort just to get LEDs lit with the simplest of basic code....I think my programming interest is going to wane very fast!.

    Now to my main intention, a simple PIC based 'pulse counter' program for a coil winder.

    If your interested, you can read about what I'm trying to achieve here ....

    http://www.electro-tech-online.com/m...am-needed.html

    (you can see my appeal for the simple PIC program didn't get much of a response, hence me having to darken this forum's doorstep and try to figure it all out myself!)
    Last edited by HankMcSpank; - 15th March 2009 at 01:08.

  6. #6
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Default

    Huh, that's funny, I copy pasted that from MCS on my computer, and it works splendidly with MCLRE_ON, I can reset MCLRE on the programmer using the little check box and that works too.<br>
    Glad Dave got you going !
    If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
    .
    Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
    .
    There simply is no "Happy Spam" If you do it you will disappear from this forum.

  7. #7
    Join Date
    Mar 2009
    Posts
    653


    Did you find this post helpful? Yes | No

    Default

    Just got hit with the next 'gotcha'!

    I was trying to get an LED to light up when the button on my low pin count was pressed - just spent ages trying to figure out why the LED wouldn't light. A check with my voltmeter revealed no matter code I tried, RA3 was always held low, a bit of Googling revealed this...

    http://www.microchip.com/forums/tm.aspx?m=270347


    F: Pushbutton doesn't work with Low Pin Count (LPC) or 28-Pin Demo Boards
    The pushbutton cannot be used on these demo boards when debugging or programming and powering them from the MPLAB IDE. The pushbutton switch is connected to the input pin that is shared with the nMCLR/VPP pin. When Debugging, this pin must be used as nMCLR and cannot be used as an input pin. When programming and leaving the PICkit 2 connected to the Demo Board to power it, the MPLAB IDE always maintains a valid output state on a programmer's nMCLR/VPP pin which prevents the switch from changing the signal value. Use the PICkit 2 Programmer software to allow the switch to be used.


    It seems I now have to assemble, & then fire up PICKit 2 to wrtie the hex to the PIC (button works as it should then).

    Mindboggling for a beginner like me, ie that there should be so many 'enviromental' hurdles to get over, when all I want is to learn the most simple of code!
    Last edited by HankMcSpank; - 15th March 2009 at 10:03.

Similar Threads

  1. Melabs U2 Programmer Command Line Options
    By Robert Wells in forum General
    Replies: 5
    Last Post: - 3rd July 2009, 02:11
  2. problems with USB programmer
    By malc-c in forum General
    Replies: 7
    Last Post: - 10th May 2007, 20:14
  3. USB programmer problems
    By uiucee2003 in forum USB
    Replies: 2
    Last Post: - 15th August 2006, 23:47
  4. General Programmer Questions
    By mslaney in forum General
    Replies: 1
    Last Post: - 17th December 2004, 18:16

Members who have read this thread : 0

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