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


Closed Thread
Results 1 to 23 of 23

Hybrid View

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

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

  3. #3


    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

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

    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.

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

    Dave
    Always wear safety glasses while programming.

  6. #6
    Join Date
    Feb 2011
    Posts
    8


    Did you find this post helpful? Yes | No

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

    I looked into ALL DIGITAL and thought it would be the answer to all my prayers...

    My Code is now as follows:

    INCLUDE "ALLDIGITAL.pbp"
    define SHOWDIGITAL 1
    Main:
    TOGGLE PORTE.0
    PAUSE 1000
    GOTO Main


    Unfortunately I still cannot get any outputs.

    When compiled I get the following messages in the results window:
    ADCON1 = 0x0F
    CMCON = 7

    I have rechecked my software and hardware by programming another Pic, a 16F690, and this programs fine.

    I am beginnig to think I may have a dodgy couple of IC's. I'll try and build another board up next Monday to rule out this, although I can program and read the pic with the setup I have now.

    Any other things I can try?

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

    I do not have this chip but give this a shot
    Code:
    '18F4523 INTERNAL OSC 8MHZ Internal oscillator block, port function on RA6 and RA7	
    @ __CONFIG    _CONFIG1H, _OSC_INTIO67_1H  & _FCMEN_OFF_1H & _IESO_OFF_1H
    @ __CONFIG    _CONFIG2H, _WDT_ON_2H & _WDTPS_512_2H
    @ __CONFIG    _CONFIG3H, _CCP2MX_PORTC_3H & _PBADEN_OFF_3H & _LPT1OSC_OFF_3H & _MCLRE_ON_3H
    @ __CONFIG    _CONFIG4L,  _STVREN_ON_4L & _LVP_OFF_4L & _XINST_OFF_4L
    DEFINE OSC 8
    OSCCON = %01110000
    ADCON1 = %00001111  
    CMCON = 7
    
    Main:
    TOGGLE PORTE.0
    PAUSE 1000
    GOTO Main
    Dave
    Always wear safety glasses while programming.

  8. #8
    Join Date
    Aug 2010
    Location
    Maryland, USA
    Posts
    869


    Did you find this post helpful? Yes | No

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

    FWIW, Dave your code works in sim, (I don't have that PIC either). 2 things I had to do: comment the configs cuz I was too lazy to go fix the .INC, and I had to tie MCLR high. So question for OP, Do you have MCLR enabled AND tied high? I ask because it's an easy to miss thing.
    -Bert

    The glass is not half full or half empty, Its twice as big as needed for the job!

    http://foamcasualty.com/ - Warbird R/C scratch building with foam!

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