18F4523 beginner needing help to blink an LED...


Closed Thread
Results 1 to 23 of 23

Hybrid View

  1. #1
    Join Date
    Jun 2004
    Posts
    18


    Did you find this post helpful? Yes | No

    Default Re: 18F4523 beginner needing help to blink an LED...

    Sorry you found that already. I deleted post.
    Last edited by Brian; - 17th February 2011 at 14:36.

  2. #2
    Join Date
    Jun 2004
    Posts
    18


    Did you find this post helpful? Yes | No

    Default Re: 18F4523 beginner needing help to blink an LED...

    This should work on an 18F2320. I have tons of code working on this chip but I don't have a way to program or test it here at work.

    I did have a copy of an old file I was playing with and I edited it and posted it here.

    Also, you need to use MPASM to compile your code with this chip. I am not sure about the 18F4523 but I would think it would too. You can select that option in MicroCode studio under options.

    As you figured out before the datasheet is the best way to understand how to setup a chip. Setting or configuring the chip you are using can be difficult when you first start but after you get the hang of it and use the data sheet it gets easier.

    '************************************************* ***************
    '* Name : 18f2320 *
    '* Author : [set under view...options] *
    '* Notice : Copyright (c) 2005 [set under view...options] *
    '* : All Rights Reserved *
    '* Date : 2/14/2005 *
    '* Version : 1.0 *
    '* Notes : *
    '* : *
    '************************************************* ***************

    DEFINE OSC 4

    OSCTUNE = 0 ' at calibrated frequency so not offset
    OSCCON = %01100000 'OSC at 4Mhz

    @ __CONFIG _CONFIG1H, _INTIO2_OSC_1H & _IESO_OFF_1H ' use internal osc
    @ __CONFIG _CONFIG2L, _PWRT_ON_2L & _BOR_ON_2L
    @ __CONFIG _CONFIG2H, _WDT_ON_2H & _WDTPS_512_2H
    @ __CONFIG _CONFIG3H, _MCLRE_OFF_3H & _PBAD_DIG_3H & _CCP2MX_OFF_3H
    @ __CONFIG _CONFIG4L, _LVP_OFF_4L


    ADCON0.0 = 0
    ADCON1 = %11001111

    CMCON = 7 'comparators off
    CVRCON = 0
    LVDCON = 0

    'set pins for output
    trisb = 0
    trisc = 0
    trisa = 0

    LED var portb.7 ' could be any pin you want here all configured for outputs

    'varible declarations

    'constants



    'set variable and misc.



    goto endsub


    endsub:


    main:

    high led
    pause 200
    low led
    pause 200

    end

  3. #3
    Join Date
    Feb 2011
    Posts
    8


    Did you find this post helpful? Yes | No

    Default Re: 18F4523 beginner needing help to blink an LED...

    Thanks for all the replies.

    I have just checked my microcode studio and it is currently using MPASM, thanks for the pointer though, if this was set wrong I would have never found it...

    I'll have a play with the code posted tomorrow, and post how I get on.

    Cheers,
    AD.

  4. #4
    Join Date
    Feb 2011
    Posts
    8


    Did you find this post helpful? Yes | No

    Default Re: 18F4523 beginner needing help to blink an LED...

    Still cannot get anything to work with this PIC18f4523.

    My code is (at the moment...):

    DEFINE OSC 8
    OSCCON = %01110000
    ADCON0 = %00000000
    ADCON1 = %00001111
    CMCON = %00000111
    TRISE=0
    TRISD=0
    PORTE.0 = 1
    PORTD.2 = 1

    I have tried various different things all day but I still cannot get any output.

    I cannot try the code Brian supplied as it was for a different PIC (well, I did try it but it did not compile with the @__... lines in place, once I'd rem'd them out it programmed fine but still did not work). I can't use a 18F2320 as this has not got enough pins for the final project I want to use this pic for, and ideally I would like at least 1 12 bit adc, preferably 2.

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


    Did you find this post helpful? Yes | No

    Default Re: 18F4523 beginner needing help to blink an LED...

    did not compile with the @__... lines in place,
    What exactly happened?

    To set the configs in code space
    http://www.picbasic.co.uk/forum/showthread.php?t=543


    Your are using MPASM as the assembler?.
    Dave
    Always wear safety glasses while programming.

  6. #6


    Did you find this post helpful? Yes | No

    Default Re: 18F4523 beginner needing help to blink an LED...

    Quote Originally Posted by thesparky View Post
    Still cannot get anything to work with this PIC18f4523.

    My code is (at the moment...):

    DEFINE OSC 8
    OSCCON = %01110000
    ADCON0 = %00000000
    ADCON1 = %00001111
    CMCON = %00000111
    TRISE=0
    TRISD=0
    PORTE.0 = 1
    PORTD.2 = 1

    I have tried various different things all day but I still cannot get any output.

    I cannot try the code Brian supplied as it was for a different PIC (well, I did try it but it did not compile with the @__... lines in place, once I'd rem'd them out it programmed fine but still did not work). I can't use a 18F2320 as this has not got enough pins for the final project I want to use this pic for, and ideally I would like at least 1 12 bit adc, preferably 2.
    You also need to set adcon2 on the PIC18F4523. It might be better to try a 10 bit a to d converter first. Maybe a PIC18F452 once you get that working you move to a 12bit converter. PBP adcin command may not work since it is geared to 8 and 10bit adc's.
    Good luck

    Nothing like a quick search. See Bruce's example
    http://www.picbasic.co.uk/forum/show...ighlight=12bit
    Last edited by mark_s; - 18th February 2011 at 15:33. Reason: add link

  7. #7
    Join Date
    Feb 2011
    Posts
    8


    Did you find this post helpful? Yes | No

    Default Re: 18F4523 beginner needing help to blink an LED...

    mackrackit

    The compiler did not seem to like the commas.
    e.g @ __CONFIG _CONFIG1H, _INTIO2_OSC_1H & _IESO_OFF_1H

    I have just tried the line:
    @__CONFIG_INTRC_OSC_NOCLKOUT

    and it seems to compile with this. I do not know what this does and do not know if it applies to this PIC, but I was just seeing if would complie.

    I am using MicroCode Studio, and when I go to View/Compile and Program Options/Compile Tab the use PBPL checkbox is ticked (although I have tried unticked) and when I go to the Assembler Tab the Use MPASM is ticked. I have not changed any of the settings (appart from PBPL) since I have been programming a 16F690 and this seems to program fine.


    mark_s

    I think I may be confusing the issue with the A-D convertor. I do not want any A-D stuff yet, I just want a simple?!? digital output to prove to myself that my setup works. I will look at ADCON2 now though. I tried another PIC18F4523 and this does not give me any output either. I have re-checked all the connections with a DVM and they all seem fine.


    If I still have no luck over the weekend then I will buy some different pics on Monday.

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


    Did you find this post helpful? Yes | No

    Default Re: 18F4523 beginner needing help to blink an LED...

    Dave
    Always wear safety glasses while programming.

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