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


Closed Thread
Results 1 to 13 of 13

Hybrid View

  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 02: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,661


    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?

    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

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

  7. #7


    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.

  8. #8


    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

Similar Threads

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

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