The worst programmer ever to grace this forum - ME!


Closed Thread
Results 1 to 40 of 50

Hybrid View

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


    Did you find this post helpful? Yes | No

    Default

    Here, this chaser works with the hardware you are using:
    MPASM required, you must comment out the config in the .inc file for 16f690 in PBP root.
    Code:
    @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
    
    main:
    portc = 0
    pause 500
    for i = 1 to 15; step -1
    portC = i
    i=i  << 1 
    pause 250
    next i
    goto main
    end
    Here's a blinkey:
    Code:
    DEFINE OSC 4
    PortA = 0
    PortB = 0
    PortC = 0
    TRISA = 0
    TRISB = 0
    TRISC = 0
    
    LED_1 var PortC.0 ' Define an alias in the program
    led_1 = 0
    
    Main:
    HIGH LED_1
    PAUSE 1000
    LOW LED_1
    PAUSE 1000
    Goto Main ' Loop forever
    end
    OK here is your code reworked:
    Code:
    DEFINE OSC 4
    LED_1 VAR BIT  ' PORT FLAG BIT
    LED_1 = 0      ' SET INITIAL VALUE
    TRISC.0 = 0 ' Make PORTC.0 an output
    
    
    Main:
    IF LED_1 = 0 THEN
    LED_1=1
    ELSE
    LED_1 = 0
    ENDIF
    PORTC.0 = LED_1
    
    
    
    
    PAUSE 250 ' Delay for 1 second (compiler errors with this line - I guess the command isn't right!)
    Goto Main ' Loop forever
    It appears as though the PIC cannot read and change it's own output without an intermediary like a flag variable. Probably
    A RMW thing, I do not know.
    Last edited by Archangel; - 14th March 2009 at 02:07.
    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.

  2. #2
    Join Date
    Mar 2009
    Posts
    653


    Did you find this post helpful? Yes | No

    Default

    Ok, many thanks for helping me.

    When I enter the code you recommended below *and*comment *all* the entries in the 16f690.inc (c:\PBP) I get 121 compiler errors (I have MPASM selected under the assembler tab ...I'm using the defaul selections when I select MPASM eg INHX8SM)...


    @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

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


    but when I reenable all the comments in the .inc file, i only get 2 errors (relating to line 63 in the corresponding asm file - if my counting is correct, it's this line __config MyConfig ....is there an easier way to establish the line that's erroring from what's being reportred in the results field?)
    Last edited by HankMcSpank; - 14th March 2009 at 10:16.

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


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by HankMcSpank View Post
    When I enter the code you recommended below *and*comment *all* the entries in the 16f690.inc
    http://www.picbasic.co.uk/forum/showthread.php?t=543
    Dave
    Always wear safety glasses while programming.

  4. #4
    Join Date
    Mar 2009
    Posts
    653


    Did you find this post helpful? Yes | No

    Default

    To me, that FAQ assumes a fair degree of previous knowledge!

    if I'm reading it right, the 16F690.inc file tells the assembler to configure the PIC for 'what's out there'?

    What's doing my head in is the sheer number of 16f690.inc files there are on my PC...

    c:\mpasm\16f690.inc (which looks a whole lot different to the others!)

    c:\pbp\16f690.inc (the one that Joe S said I should comment out - not sure which lines ...all of them?)

    c:\pbp\inc\ (a whole lot of files in here!)


    At the risk of sounding incredibly slow - help!

    Once again, all I want is the correct code to 'set the chip correctly' for me to then start my simple journey to get an LED, firstly lit, then flashing (wheee!)

    Joe.S kindly posted a 'chaser' earlier ( & said I needed to comment out the inc file in c:\pbp ....which lines?!)

    I'm perplexed that this chip should be so troublesome at the very first base ....from a newbie's perspective, it's probably the most prevelant since it's bundled in with the low pin count board on on the Pickit 2 starter. It might have been useful to have a "So you got a 16F690 PIC & you've arrived here after using the Pickit 2....here are some things you should know/do!" type thread.

    I'm an absolute novice here.....are we saying there's an issue with the PIC itself...or just this particular PIC in combination with PICBasic? (fwiw, I'm suspecting the latter as the PIC is fine using the Micropchip Assembler)

    Many thanks in anticipation.
    Last edited by HankMcSpank; - 14th March 2009 at 14:41.

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


    Did you find this post helpful? Yes | No

    Default

    In your 16F690.INC only comment out the __config line. Leave everything else
    as-is.

    Then something like this should work if you're disabling analog inputs & comparators;
    Code:
    @MyConfig = _INTRC_OSC_NOCLKOUT & _WDT_OFF & _PWRTE_ON  
    @MyConfig = MyConfig & _MCLRE_ON & _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
    
    
    main:
        portc = 0
        pause 500
        for i = 1 to 15
        portC = i
        pause 150
        next i
        goto main
        end
    Regards,

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

  6. #6
    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.

  7. #7
    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.

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