18F4550 issue with simple program.


Closed Thread
Results 1 to 12 of 12

Hybrid View

  1. #1
    Join Date
    Feb 2004
    Location
    Michigan, USA
    Posts
    305

    Default 18F4550 issue with simple program.

    I'm having a problem getting a really simple program to run on an 18F4550. It just a couple of blinky LED's to verify the PIC is alive. I can program it fine and read back from the device but cannot get this program to work.

    I'm running this on a 20mhz resonator using HS+PLL with PLL/5. MCLR is disabled, low voltage programming disabled. What am I missing?!

    Define OSC 48
    Define ADC_BITS 10 ' Set number of bits in result
    Define ADC_CLOCK 3 ' Set clock source (3=rc)
    Define ADC_SAMPLEUS 50 ' Set sampling time in uS
    adval var word ' Create adval to store result

    TRISA = %11111111 ' Set PORTA to all input
    ADCON1 = %10001111 ' Set PORTA analog and right justify result
    TRISB = %00000000
    TRISC = %00000000

    RCSTA.7 = 0

    loop1:
    Portc.6 = 1
    pause 100
    Portc.7 = 1
    pause 200
    portc.6 = 0
    portc.7 = 0
    pause 200
    goto loop1
    End

  2. #2
    Join Date
    Oct 2009
    Posts
    583


    Did you find this post helpful? Yes | No

    Default Re: 18F4550 issue with simple program.

    deleted after posting

  3. #3
    Join Date
    May 2013
    Location
    australia
    Posts
    2,388


    Did you find this post helpful? Yes | No

    Default Re: 18F4550 issue with simple program.

    you might need another read of the hardware manual for a 18F4550


    ADCON1 = %10001111 ' Set PORTA analog and right justify result ?????????????


    sets all analogue pins digital

    you need
    ADCON1 = %00001010 'Set PORTA analog
    ADCON2.7=1 ' right justify result

    ps

    where does this bogus line come from
    ADCON1 = %10001111 ' Set PORTA analog and right justify result ?????????????
    it comes up repeatedly

  4. #4
    Join Date
    Feb 2004
    Location
    Michigan, USA
    Posts
    305


    Did you find this post helpful? Yes | No

    Default Re: 18F4550 issue with simple program.

    Yes you're right. I hadnt changed the comment but the setting is correct for what I need. Still, It is not running. I've noticed that the code is being loaded into the end of the program space and not the beginning. Is this an issue and how do I resolve it if it is?

    I'm using PBP 2.60A, MCS 3.0.0.5 and MPLAB 8.20A

  5. #5
    Join Date
    Jul 2009
    Location
    Ohio, USA
    Posts
    57


    Did you find this post helpful? Yes | No

    Default Re: 18F4550 issue with simple program.

    Is MCLR tied high?

  6. #6
    Join Date
    Oct 2009
    Posts
    583


    Did you find this post helpful? Yes | No

    Default Re: 18F4550 issue with simple program.

    Not sure if this helps, but this is a section of code that uses an 18f4580, with four pots on port A

    Code:
    ; config settings 18F2550/4550/18F4580, 20mhz crystal
    ASM  
      __CONFIG    _CONFIG1H, _OSC_HSPLL_1H
      __CONFIG    _CONFIG2L, _PWRT_ON_2L  
      __CONFIG    _CONFIG2H, _WDT_ON_2H & _WDTPS_512_2H
      __CONFIG    _CONFIG3H, _PBADEN_OFF_3H
      __CONFIG    _CONFIG4L, _LVP_OFF_4L & _XINST_OFF_4L
    ENDASM
    
    DEFINE  OSC 48
    ADCON1 = $0F
    clear
    
    
    DEFINE ADC_BITS 10                              ' Set-up ADC for fastest 10-bit results
    DEFINE ADC_CLOCK 2
    DEFINE ADC_SAMPLEUS 5
    INCLUDE "DT_Analog.pbp"
    
    MaxSetPoint  CON 500                            ' Pot fully clockwise - gives max setting 50 degrees
    MinSetPoint  CON 100                            ' Pot fully counter clockwise - sets min setting 10 degrees
    ADbits = 14                                     ' set A/D resolution to 14-bits
    CMCON = 7                                       ' disable Comparators
    ADCON1 = %00001011                              ' sets up Analogue pins
    ADCON2.7 = 1                                    ' ADFM bit isn't in ADCON1 anymore
    
    ;----[Port settings]----------------------------------------------------
    
    TRISA = %11001111
    It uses DT's analogue include file, which might be worth downloading and including in your own code

  7. #7
    Join Date
    Feb 2004
    Location
    Michigan, USA
    Posts
    305


    Did you find this post helpful? Yes | No

    Default Re: 18F4550 issue with simple program.

    Quote Originally Posted by Mike2545 View Post
    Is MCLR tied high?
    No. Does the PicKit 3 programmer hold it high or low when powering the target board?

    I do have it disabled in the config bits.

Similar Threads

  1. USB issue - 18F4550
    By Scampy in forum mel PIC BASIC Pro
    Replies: 14
    Last Post: - 20th February 2013, 20:49
  2. 18F4550 issue
    By Christopher4187 in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 4th February 2013, 06:27
  3. Simple LED driving issue - setup?
    By George in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 28th March 2011, 01:54
  4. Code issue with a flashing light(simple question)
    By IAmTheAnswer in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 8th May 2010, 11:46
  5. Simple 4 line LCD display with 18F4550
    By pic-ker in forum Code Examples
    Replies: 4
    Last Post: - 9th April 2007, 02:58

Members who have read this thread : 1

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