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

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

    Hi,

    I have just started using PICBASIC Pro and have had a lot of problems trying to work out what I am doing. I started using a 16F690 and after what seemed like weeks finally managed to get it to blink an LED. I then could work out what I wanted to do after this, which was to read in a temperature, display it on an LCD and then switch on a fan at certain temperatures

    I am now working on a different project with a different device and have hit a wall again. Ideally I would like to repeat what I have done with the 16F690, just so I can learn about this new device. I want to use a 18F4523, but I cannot even get an LED to blink yet.

    I have printed off and read the data sheet, but I cannot see what to do to get the device working. I have also tried the search function on the forums, but this device does not seem widely used.

    I don't mind changing devices either if this will help. I need around 30 inputs, be able to read a RTC (1307)? in the future, and have at least two 12 bit ADC's.

    Can anyone help me with the code needed to get this device (PIC18F4523) to blink an led, using the internal oscillator (4Mhz?). I do not care which pin the led is on. I know it will be a few lines that set certain registers but I have tried hundreds of different ways and keep failing.

    Once I have this working I'm sure I'll have a lot more problems....

    Thanks.

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

    Post your code and configs so we can see what you have done.
    Dave
    Always wear safety glasses while programming.

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

    Hi,

    Thanks for taking the time to look. I tried to reply earlier, but I guess something went wrong, but if another post pops up just ignore that one....

    I have not got any code yet as I have been trying lots of different things to get this to work. I have been trying for a week now to no avail. I just can't get anything to happen.

    I had a lot of problems with a PIC16F690 before, until I set ANSEL and ANSELH. I guess it is something like this again, but I cannot find what, and have almost given up.

    I thought I'd try this forum to see if anyone else had used thie 18F4523, and if so what they did to set it up.

    As for code, I guess I would do something like this:

    LH:
    PortB.3 = 1 '(just an example, any port would do!!!)
    Pause 1000
    PortB.3 = 0
    Pause 1000
    Goto LH
    End

    But I know I have to set up the outputs, Osc etc first and this is where I am getting stuck. I have tried so many different variations but I am not getting anywhere.

    I guess I should really keep looking through the 380 pages of the data sheet, and eventually I may come accross what I'm after, but I am new to this and was hopeing not to have to spend another few weeks before I can get anything to happen....

    As for the harware, I have just got the VDD connected to +5v and VSS connected to GND (both sets of VDD and VSS). I am using 10Uf, and 100nf decoupling capacitors. For the outpt I am just looking at various pins using a volt meter. I am programming it using a Pickit II programmer, and I am not sure what pinout I am using for this as I have not got the circuit with me at the moment.

    So in short I have not got the experience to go through the data sheet to find the info that I need, Please help!. Once I have something that I know should work I can use this to see if my hardware setup is fine, ie not missing any pullups etc (I think I tried MCLR pullup once).

    Thanks.

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

    ADCON1 configures analog or digital operation on this device.

    As a note, I was really confused at first when I went to get the datasheet. It was only 54 pages! Well it seems they have a big note at the beginning explaining this is just the differences between this and another chip. Further they want me to use that datasheet except for the parts listed in the 54 page sheet. Anyway, the A/D stuff is in the "short sheet" So I suspect you are reading the other one as stated by you it is 380 pages.
    -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!

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

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

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