"hello world" with 18f6680


Closed Thread
Results 1 to 40 of 92

Hybrid View

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


    Did you find this post helpful? Yes | No

    Default

    How are you programming the fuses? In the code or the *.inc??

    Either way, post the config settings. The 18s are different ...


    This is a snippet of my 18F4320.inc
    Code:
    	
    
    	
    	CONFIG OSC = HS
    
    	CONFIG LVP = OFF
    
    	CONFIG BOR = OFF
    
    	CONFIG MCLRE = OFF
    
      
    
      ;      __CONFIG    _CONFIG1H, _XT_OSC_1H
    
      ;      __CONFIG    _CONFIG2H, _WDT_ON_2H & _WDTPS_512_2H
    
      ;      __CONFIG    _CONFIG4L, _LVP_OFF_4L
    Dave
    Always wear safety glasses while programming.

  2. #2
    Join Date
    Apr 2006
    Location
    Alberta Canada
    Posts
    166


    Did you find this post helpful? Yes | No

    Default

    ok... i have tried to get this to work lots since last year, adn it still wont do anything. i have pulled apart both boards and checked all the solder joints with my meter, and have gone over and over the design to make sure everything is wired properly. i have replaced the OSC with another one. there is .1uf caps spead out over the board, and i have a 1M ohm resistor from PGM to ground.

    i can program code into the chip, and i can read it back, it just wont run. i have an LED connected from D4 to a resistor and then to gnd. all the other ports i have put my meter on and watched for voltage changes.

    my code is:

    DEFINE OSC 20
    pause 500
    start:
    High porta.0
    high porta.1
    High porta.2
    high porta.3
    High porta.4
    High porta.5
    High porta.6
    High porta.7

    High portb.0
    high portb.1
    High portb.2
    high portb.3
    High portb.4
    High portb.5
    High portb.6
    High portb.7

    High portc.0
    high portc.1
    High portc.2
    high portc.3
    High portc.4
    High portc.5
    High portc.6
    High portc.7

    High portd.0
    high portd.1
    High portd.2
    high portd.3
    High portd.4
    High portd.5
    High portd.6
    High portd.7

    High porte.0
    high porte.1
    High porte.2
    high porte.3
    High porte.4
    High porte.5
    High porte.6
    High porte.7

    High portf.0
    high portf.1
    High portf.2
    high portf.3
    High portf.4
    High portf.5
    High portf.6
    High portf.7

    High portg.0
    high portg.1
    High portg.2
    high portg.3
    High portg.4
    high portg.5
    High portg.6
    high portg.7

    pause 300

    low porta.0
    low porta.1
    low porta.2
    low porta.3
    low porta.4
    low porta.5
    low porta.6
    low porta.7

    low portb.0
    low portb.1
    low portb.2
    low portb.3
    low portb.4
    low portb.5
    low portb.6
    low portb.7

    low portc.0
    low portc.1
    low portc.2
    low portc.3
    low portc.4
    low portc.5
    low portc.6
    low portc.7

    low portd.0
    low portd.1
    low portd.2
    low portd.3
    low portd.4
    low portd.5
    low portd.6
    low portd.7

    low porte.0
    low porte.1
    low porte.2
    low porte.3
    low porte.4
    low porte.5
    low porte.6
    low porte.7

    low portf.0
    low portf.1
    low portf.2
    low portf.3
    low portf.4
    low portf.5
    low portf.6
    low portf.7

    low portg.0
    low portg.1
    low portg.2
    low portg.3
    low portg.4
    low portg.5
    low portg.6
    low portg.7
    pause 300
    goto start
    end



    and the fuses are set as:

    OSC "HS"
    System clock "disabled"
    power up timer "disabled"
    brown out reset "enabled"
    brown out voltage "2.0V"
    watchdog timer " enabled"
    watchdog postscaler "1:128"
    ccp2 multiplexed with "RC1"
    mclr pin function "reset"
    overflow reset "enabled"
    LVP "disabled"
    boot block "not protected"

    im using microcode studio, mpasm and an epic programmer.

  3. #3
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    [QUOTE=dragons_fire;49764]
    Code:
    DEFINE OSC 20
    pause 500
    trisa = 0 : trisb = 0 : trisc = 0 : trisd = 0
    trise = 0 : trisf = 0 : trisg = 0 : trish = 0
    start:
    porta = $ff : portb = $ff : portc = $ff
    portd = $ff : porte = $ff : portf = $ff
    portg = $ff
    pause 300
    porta = 0 : portb = 0 : portc = 0 : portd = 0
    porte = 0 : portf = 0 : portg = 0
    pause 300
    goto start
    end
    Easier to read in my mind And accomplishes the same thing.
    What I like to do when I'm having initial problems is something like this:
    counter var word : trisb = 0 : trisd = 0
    main:
    counter = counter + 1
    portb = counter.lowbyte : portd = counter.highbyte
    goto main
    Something simple like that. At least that way, on each successive pin, I'll see half the frequency of the previous pin.

    All of the Vdd/AVdd tied together as well as the Vss/AVss? Multiple power/ground pins ya know... Actually, I know you know...Treadbot...worked...sort of...sorry to hear it didn't work 100% for ya. Looked like fun.
    Pull up to +5v on MCLR? Preferably thru a resistor...
    Volts on the OSC pins should give about a 1.5v signal, give or take a bit.

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


    Did you find this post helpful? Yes | No

    Default fuses

    Hello Dragon's_fire.
    Here are some config fuses taken from the .INC in the MPASM directory. it might help.
    Code:
    @ __CONFIG _OSC_HS_1H & _LVP_OFF & _WDT_ON_2H & _BOR_OFF_2L &  _PWRT_ON_2L & _WRT0_OFF_6L & _CPD_OFF_5H
    JS
    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.

  5. #5
    Join Date
    Apr 2006
    Location
    Alberta Canada
    Posts
    166


    Did you find this post helpful? Yes | No

    Default

    Skimask, i tried that code you posted, still nothing,... im going up to my otehr computer to see if i can attach a copy of the schematic... i dont think i messed up the hardware, but im kinda scared i did.. when i put my meter across:
    OSC1-OSC2, it shows 0V
    OSC1-GND, it shows 2.5V
    OSC2-GND, it shouws 3.6V

    PGM is grounded through a 1Mohm resistor,
    all power and ground pins are connected including Avdd and Avss

  6. #6
    Join Date
    Apr 2006
    Location
    Alberta Canada
    Posts
    166


    Did you find this post helpful? Yes | No

    Default

    heres the schematic.. i cleaned it up a little, and all the "empty" pins go to headers for i/o that go to a different board. its a screens hot from eagle cad, so you also wont see the v-reg and capacitors on it either. the voltage regulator is on the top board, and the capacitors were drawn separately, and then spaced around when the board was routed.


  7. #7
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by dragons_fire View Post
    OSC1-OSC2, it shows 0V
    OSC1-GND, it shows 2.5V
    OSC2-GND, it shouws 3.6V
    OSC1-2 - should show more than that, but your meter probably won't respond quick enough. Got an AC setting you can try?

    OSC1/2 - GND - both sound good to me.

    In your schematic, is that a 20Mhz resonator, crystal?
    Try changing your config's to use a different type of clock, R/C, external, whatever, see what happens.

  8. #8
    Join Date
    Apr 2006
    Location
    Alberta Canada
    Posts
    166


    Did you find this post helpful? Yes | No

    Default

    i tried checking voltage again. i get around 3mV DC across OSC1-OSC2. on the AC setting it shows nothing but im using a digital meter which might be too slow. i dug out my analog meter, but i have no clue where the leads are for it....

    the OSC is a 20.0Mhz ceramic resonator with built in caps. its mountet fairly close to the PIC.

    i have tried some of the different clock settings with no luck and i have switched resonators once just in case it was a bad one...

  9. #9
    Join Date
    Apr 2006
    Location
    Alberta Canada
    Posts
    166


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by skimask;49770[code
    DEFINE OSC 20
    pause 500
    trisa = 0 : trisb = 0 : trisc = 0 : trisd = 0
    trise = 0 : trisf = 0 : trisg = 0 : trish = 0
    start:
    porta = $ff : portb = $ff : portc = $ff
    portd = $ff : porte = $ff : portf = $ff
    portg = $ff
    pause 300
    porta = 0 : portb = 0 : portc = 0 : portd = 0
    porte = 0 : portf = 0 : portg = 0
    pause 300
    goto start
    end
    [/code]
    just wondering if doing it this way decreases code size too, or if it just makes for less typing??? im working on writing some code for this project (if i can ever get the board to work) and i know it would make the code smaller to look at if i did it as above, but i think it would be harder to write since i have labeled all my ports for what they do, so when i write it, i use those "labels"....

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


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by dragons_fire View Post
    just wondering if doing it this way decreases code size too, or if it just makes for less typing??? im working on writing some code for this project (if i can ever get the board to work) and i know it would make the code smaller to look at if i did it as above, but i think it would be harder to write since i have labeled all my ports for what they do, so when i write it, i use those "labels"....
    The hex file comes out the same, this works for very organised people, who know the subject material very well, I suggest you do it the other way with loads of comments so a year from now, when your are even better than you are now . . you can make sense of what you did as you rewrite your code . . . and you will.
    JS
    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.

  11. #11
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by dragons_fire View Post
    just wondering if doing it this way decreases code size too, or if it just makes for less typing??? im working on writing some code for this project (if i can ever get the board to work) and i know it would make the code smaller to look at if i did it as above, but i think it would be harder to write since i have labeled all my ports for what they do, so when i write it, i use those "labels"....
    Nope, it's just a 'me-ism' thing.
    I like to get as much code on a screen as I can. I hate scrolling up and down and if I've got a longer routine, I can bunch it all up in one page. It's my STYLE, if you can call it that.
    Some people hate it, I mean really HATE it...too bad, so sad, don't care. If a guy has half a brain, they'd know how to use the 'replace' shortcut in WORD to put a single command on each line, and if not that, they'd at least know how to split it up. For instance, my latest project is about 1700 lines of the bunched up code, fills an 18F4620...no extra line breaks, no extra spaces, no nothing, etc. If I was to spread that out, make it "right", I estimate it would take up about 8500 lines. Forget that noise. Most of the time, my 2nd monitor is turned 90 right and Windows adjusted accordingly, like it's in 'Portrait' mode instead of the normal landscape...oh and it's 1600x1200, so that really packs it in there.
    What's a guy expect for FREE help?

    But like Joe said, it's all personal preference. Get your own method, stick with it, it's all good...

  12. #12
    Join Date
    Apr 2006
    Location
    New Hampshire USA
    Posts
    298


    Did you find this post helpful? Yes | No

    Talking posting your “problem code”

    skimask’s method is perfect for his style of programming.

    as Joe said: “people, who know the subject material very well”

    But if anyone wants the forum to help with their code (skimask never needs help), I wouldn’t advise posting your “problem code” in this style.

    -Adam-
    Ohm it's not just a good idea... it's the LAW !

  13. #13
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Pic_User View Post
    (skimask never needs help)
    -Adam-
    'taint so!
    I think the main difference is in the use of the 'Search' function here and at Google, or wherever...I'd be willing to bet I spend more time researching HOW to do stuff vs. actually doing it.
    And this weekend, I could sure use some help doing some sanding, and in fact, I might even need help cleaning out all of those left over full cans of preferred beverages from the 'fridge in the basement...

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


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by dragons_fire View Post

    and the fuses are set as:

    OSC "HS"
    <font color=red>System clock "disabled"
    </font color>power up timer "disabled"
    brown out reset "enabled"
    brown out voltage "2.0V"
    watchdog timer " enabled"
    watchdog postscaler "1:128"
    ccp2 multiplexed with "RC1"
    mclr pin function "reset"
    overflow reset "enabled"
    LVP "disabled"
    boot block "not protected"

    i'm using microcode studio, mpasm and an epic programmer.
    What does it mean system clock disabled? Does this mean no oscillator?
    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.

  15. #15
    Join Date
    Apr 2006
    Location
    Alberta Canada
    Posts
    166


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Joe S. View Post
    What does it mean system clock disabled? Does this mean no oscillator?
    im not sure... i have tried it on both enabled and disabled. those were taken from the config settings of my programmer.

  16. #16
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by dragons_fire View Post
    im not sure... i have tried it on both enabled and disabled. those were taken from the config settings of my programmer.
    System clock is actually OSCSEN.
    While a program is running, you can switch the clock source from the main clock source (crystal, R/C, whatever) over to the Timer1 clock source, and back again.

  17. #17
    Join Date
    Apr 2006
    Location
    Alberta Canada
    Posts
    166


    Did you find this post helpful? Yes | No

    Default

    GOOD TO KNOW... i learn so much from all of you on here.... i know these PICs say they are static sensitive, but how bad is it?? should i be wearing a strap every time i think about looking at it?? or do i really need to worry about it. i know with the 16f devices i have used, they say they are static sensitive, but i have never worried about it and never had any problems...

  18. #18
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by dragons_fire View Post
    GOOD TO KNOW... i learn so much from all of you on here.... i know these PICs say they are static sensitive, but how bad is it?? should i be wearing a strap every time i think about looking at it?? or do i really need to worry about it. i know with the 16f devices i have used, they say they are static sensitive, but i have never worried about it and never had any problems...
    I haven't COMPLETELY blown a PIC up with static...YET! I know how dry it gets where you're at (remember, I'm just a bit south-east of you). My 'shop' is in the basement, usually about 20% humidity in the winter, carpet on the floor, and so on and so on.
    I think, that is, THINK, the worst I've done to a PIC is blow out an output driver or two on a few PICs...and I'm not even 100% sure it was static that did it. Probably from putting them in the socket backwards, etc.
    However, I've heard that the 18F's are quite a bit more static sensitive than the 16F's were, probably due to the smaller gate size on the die...not sure...don't care. As long as I don't smoke anymore, I'm all good...

Similar Threads

  1. 18f6680 N/C
    By mackrackit in forum Off Topic
    Replies: 2
    Last Post: - 29th April 2008, 20:21
  2. need help with "hello world" in hyperterm
    By ericmiles in forum Serial
    Replies: 3
    Last Post: - 31st October 2007, 15:08
  3. 18F6680 and portd problems.
    By jkbh in forum mel PIC BASIC Pro
    Replies: 10
    Last Post: - 6th June 2005, 10:54

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