"hello world" with 18f6680


Closed Thread
Results 1 to 40 of 92

Hybrid View

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

    Default "hello world" with 18f6680

    i know someone is going to say something about reading the datasheet, or looking in the manual, but im having some trouble with this, and im sure its just something small.

    heres the code, and im flashing a LED on D.4 and setting all the config stuff in my programmer, since i cant figure out the defines.

    <code>
    DEFINE OSC20
    PORT.4 = 0

    start:
    high PORTD.4
    pause 500
    Low PORTD.4
    pause 500
    goto start

    end
    </code>

    the hardware is a PIC18F6680, with a LED and resistor connected to ground.

    the config fuses HS OSC, brownout 2.0v, watchdog enabled, lvp disabled

  2. #2
    Join Date
    Jun 2006
    Location
    Mountain View California
    Posts
    7


    Did you find this post helpful? Yes | No

    Default

    Could it be that you forgot to put a space between "OSC" and "20"?
    Try changing DEFINE OSC20 to DEFINE OSC 20.

    Ben

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


    Did you find this post helpful? Yes | No

    Default

    don't tell us what your problem is in case we could help
    Steve

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

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


    Did you find this post helpful? Yes | No

    Default

    yeah, i guess i should mention whats happening or not happening...

    so the LED doesnt light up, ive checked for voltage with my meter and theres nothing from the pin to ground..

    i should also mention that i caught that missing space (OSC 20) right after i posted, but it still didnt help... the hardware should be good, i think im jsut missing something in the software.

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


    Did you find this post helpful? Yes | No

    Default

    ok, here is the last version of my code... still cant get it to work...

    <code>

    DEFINE OSC 20

    TRISA = 0
    TRISB = 0
    TRISC = 0
    TRISD = 0
    TRISE = 0
    TRISF = 0
    trisg = 0

    LCDA1 VAR PORTE.6
    LCDB1 VAR PORTE.7
    LCDC1 VAR PORTE.3
    LCDD1 VAR PORTG.4
    LCDE1 VAR PORTG.3
    LCDF1 VAR PORTE.5
    LCDG1 VAR PORTE.4
    LCDDP1 VAR PORTG.2

    LCDA2 VAR PORTD.2
    LCDB2 VAR PORTD.3
    LCDC2 VAR PORTE.0
    LCDD2 VAR PORTG.0
    LCDE2 VAR PORTG.1
    LCDF2 VAR PORTD.1
    LCDG2 VAR PORTD.0
    LCDDP2 VAR PORTE.1

    LCDA3 VAR PORTD.6
    LCDB3 VAR PORTD.7
    LCDC3 VAR PORTB.0
    LCDD3 VAR PORTB.1
    LCDE3 VAR PORTE.2
    LCDF3 VAR PORTD.5
    LCDG3 VAR PORTD.4

    pause 500

    'MAIN PROGRAM\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/

    start:
    high LCDa1
    high LCDb1
    high LCDc1
    high LCDd1
    high LCDe1
    high LCDf1
    high LCDg1
    high LCDdp1

    high LCDa2
    high LCDb2
    high LCDc2
    high LCDd2
    high LCDe2
    high LCDf2
    high LCDg2
    high LCDdp2

    high LCDa3
    high LCDb3
    high LCDc3
    high LCDd3
    high LCDe3
    high LCDf3
    high LCDg3

    pause 500
    low LCDa1
    low LCDb1
    low LCDc1
    low LCDd1
    low LCDe1
    low LCDf1
    low LCDg1
    low LCDdp1

    low LCDa2
    low LCDb2
    low LCDc2
    low LCDd2
    low LCDe2
    low LCDf2
    low LCDg2
    low LCDdp2

    low LCDa3
    low LCDb3
    low LCDc3
    low LCDd3
    low LCDe3
    low LCDf3
    low LCDg3
    pause 500
    goto start
    end
    </code>

    so it powers up, but it doesnt put and of the ports high.. there is only one LED connected, the rest of the pins arent connected. but i have put my meter across them to see if there is any voltage...

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


    Did you find this post helpful? Yes | No

    Default

    3 things,
    1. no configuration fuses.. make sure you set the right osc mode
    2. disable all multiplexed analog converter, comparator, voltage reference or else fancy stuff
    3. with 18Fs, you want to use LAT instead of PORT to avoid R-M-W behaviour. The best solution is often write to the whole port in one shot instead of using multiple High/Low lines.
    Steve

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

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