What is theabsolutely minimal hardware to run BLINK with a PIC18F4620?


Closed Thread
Results 1 to 13 of 13
  1. #1

    Default What is theabsolutely minimal hardware to run BLINK with a PIC18F4620?

    I am trying to get a PIC18F4620 to blink a LED.

    I think I have enough hardware bit I cannot get it to work.

    Code:
    '****************************************************************
    ' Name        : BLINK.pbp  Based on the MeLabs code examples for Lab-X1
    ' Compiler    : PICBASIC PRO Compiler 3.0.7.4
    ' IDE            : MCSP 5.0.0.5
    ' Assembler   : MPASM
    ' Target PIC  : 18F4620 in 40 pin PDIP.
    ' Oscillator    : internal IntRC (Clkout) set in Config fuse at code burn time
    ' Programmer  : MeLabs U2 USB 
    ' Keywords    : BLINK LED
    ' Description : Minimal hardware PIC18F4620 in 40 pin DIP
    '****************************************************************
    '
    'The following program is a simple test to blink an LED on and off.  
    ' Hardware    : minimal breadboard  7805, input cap, output cap
    '
    'pin 1 = reset, tied to +5
    'pin 11 +5V     
    'Pin 12 Gnd     
    '1 uF cap between pins 11 & 12
    'Pin 31 Gnd
    'Pin 32 +5V
    '1 uF cap between pins 31 & 32
    'Pin 33 Port B.0 has LED to Gnd via 1k resistor
    'Program is compiled with PBP3.0.7.4 and MCSP 5.0.0.5
    'At program time the IntRC (ClkOut) oscillator is selected.
    
       LED1  VAR  PORTB.0   ' Assign name "LED1" to PORTB.0 on pin 33
    
       OSCCON  = %11111111  '
                ' 0-------  IDLEN 0 = enters SLEEP on Sleep command = 4 uA
                ' 1-------  Enters IDLE and draws 550 uA
                ' -111----  IRCF <2:0> Int Osc freq select 111 = 8 MHz
                ' ----0---  OSTS Osc Startup Status - read only - ignore
                ' -----0--  IOFS IntOsc Freq Stable  - read only - ignore
                ' ------00  System Clock Select 00 = Primary Osc
       WDTCON  = %00000001  ' enables SWDT - needs WDT OFF in config 
                ' xxxxxxx1  SWDTEN  software controlled WDT enabled
       ADCON0  = %00000000  ' ADC OFF
                ' xx0000--  CH<3:0> select analog channels
                ' ------0-  1 = Go, 0 = Done
                ' -------0  1 = ADC ON, 0 = ADC OFF
       ADCON1 = %00001111 'VRefs = Vdd & Vss, All ports digital  
                ' 00------  unimplimented                 
                ' --00----  VCFG<1:0> Select Vcc & Gnd as ADC references
                ' ----0110  PCFG<3:0> A/D Port configuration see register 19-2 
    '   ADCON2  = %00111111 'Left just (=8 bit), ADacq time = 20 Tad, ADClk = Frc   
                ' 0-------  ADFM 0 = Left Justified 8 bit mode
                ' -x111---  ACQ<2:0> A/D acquisition time = 20 Tad
                ' -----111  ADCS<2:0> A/D conversion clock select = Fr/c
       CMCON   = %00000111  ' Comparators OFF 
                ' 00------  No comparator outputs
                ' --00----  No inversion on outputs
                ' ----0---  Vin to pins AN0 & AN1
                ' -----111  Comparators OFF 
    
    mainloop:
       High LED1        ' Turn on LED connected to PORTB.0
       Pause 500       ' Delay for .5 seconds
    
       Low LED1         ' Turn off LED connected to PORTB.0
       Pause 500       ' Delay for .5 seconds
    
       Goto mainloop   ' Go back to loop and blink LED forever
       
       End
    When I program the PIC I select INTRC(ClkOut) as the clock option

    Any help gratefully received.
    Thanks
    BrianT
    Last edited by Archangel; - 30th October 2013 at 03:01. Reason: code tags

  2. #2
    Join Date
    Nov 2012
    Posts
    2


    Did you find this post helpful? Yes | No

    Default Re: What is theabsolutely minimal hardware to run BLINK with a PIC18F4620?

    Don't want to be fatuous, but start by double checking that the LED is the right way around. A common fault.

    Cheers Ron...

  3. #3
    Join Date
    Nov 2007
    Location
    West Covina, CA
    Posts
    219


    Did you find this post helpful? Yes | No

    Default Re: What is theabsolutely minimal hardware to run BLINK with a PIC18F4620?

    I would also try changing LED1 variable assignment to:
    Code:
    LED1 VAR LATB.0 ' Assign name "LED1" to LATB.0 on pin 33
    Louie

  4. #4
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    2,588


    Did you find this post helpful? Yes | No

    Default Re: What is theabsolutely minimal hardware to run BLINK with a PIC18F4620?

    Isn't 1K on the LED a bit high?

    I usually have 330R.

    Robert

  5. #5


    Did you find this post helpful? Yes | No

    Default Re: What is theabsolutely minimal hardware to run BLINK with a PIC18F4620?

    The LED polarity is correct. With the MCU removed, the LED lights when 5V is applied to PortB.0

  6. #6


    Did you find this post helpful? Yes | No

    Default Re: What is theabsolutely minimal hardware to run BLINK with a PIC18F4620?

    Thanks for the tip. I tried LATB.0 and it makes no difference.

  7. #7


    Did you find this post helpful? Yes | No

    Default Re: What is theabsolutely minimal hardware to run BLINK with a PIC18F4620?

    1k with high brightness LEDs is plenty.

    I think the problem is a missing register definition somewhere but I can't find it.

    Cheers
    BrianT

  8. #8
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Default Re: What is theabsolutely minimal hardware to run BLINK with a PIC18F4620?

    Hi Brian,
    I would guess it's something in the default configs that is/are? at odds with your code, better to hand code the configs so you know what you have.
    DEFINE OSC ??
    Last edited by Archangel; - 30th October 2013 at 03:02.
    If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
    .
    Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
    .
    There simply is no "Happy Spam" If you do it you will disappear from this forum.

  9. #9
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    3,796


    Did you find this post helpful? Yes | No

    Default Re: What is theabsolutely minimal hardware to run BLINK with a PIC18F4620?

    Bit 7 of OSCCON, should not be a zero?

    Ioannis

  10. #10
    Join Date
    Apr 2007
    Location
    Pennsylvania, USA
    Posts
    158


    Did you find this post helpful? Yes | No

    Default Re: What is theabsolutely minimal hardware to run BLINK with a PIC18F4620?

    bit 7 only matters if using sleep

    add led1=0 near the beginning of your code

    You should also define the osc to 08
    Shawn

  11. #11
    Join Date
    May 2008
    Location
    Italy
    Posts
    825


    Did you find this post helpful? Yes | No

    Default Re: What is theabsolutely minimal hardware to run BLINK with a PIC18F4620?

    Try

    OSCCON = %01111000
    OSCTUNE = %01000000
    DEFINE OSC 32

    I use "INTIO2" but your setting should make no difference if you don't use osc pins as digital in/out.

    Cheers

    Al.
    All progress began with an idea

  12. #12
    Join Date
    Sep 2010
    Location
    Las Vegas, NV
    Posts
    305


    Did you find this post helpful? Yes | No

    Default Re: What is theabsolutely minimal hardware to run BLINK with a PIC18F4620?

    I'm not the best at reading the manual for this chip but from what I read on the data sheet OSCTUNE = %01000000 bit 6(PLLEN) can only be used with a 4 or 8 MHz oscillator.

    OSCCON = %01111000 defines a 8 MHz internal oscillator. I think the first part should be of OSCCON should be OSCCON = %011111xx that defines an internal stable oscillator. I don't understand what the last two bits do so that would take some more exploration. It looks like you've got a plethora of options that depend on your specific situation.

    In smaller chips the port usually needs to be set to digital for LEDs to light. I couldn't figure out how to do that for this chip.

    Also, if the LED takes 2.2 volts of the 5 volts applied that leaves 2.8 volts for the 1k resistor. That's only 2.8 milliamps if the chip doesn't drop any voltage. I think that's low and am surprised it will light with 5 volts applied.

    I hope it helps.

  13. #13
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    2,588


    Did you find this post helpful? Yes | No

    Default Re: What is theabsolutely minimal hardware to run BLINK with a PIC18F4620?

    He is using high brightness LEDs. They might consume less than the average 20mA used by common LEDs (might be very high efficiency LEDs).

    Robert

Similar Threads

  1. ADCIN with PIC18F4620
    By Brian J Walsh in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 4th July 2008, 02:25
  2. PIC18F4620 Troubles
    By CluckShot in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 16th May 2007, 04:02
  3. pic18f4620 and flashlab77
    By igeorge in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 5th November 2006, 02:00
  4. LCD + keyboard matrix minimal I/O
    By RFsolution in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 21st June 2006, 20:49
  5. Sound and sound control with minimal parts
    By bartman in forum General
    Replies: 23
    Last Post: - 18th January 2005, 15:08

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