blink a single led


Closed Thread
Results 1 to 28 of 28

Hybrid View

  1. #1
    Join Date
    Apr 2008
    Posts
    85


    Did you find this post helpful? Yes | No

    Default Re: blink a single led

    tks for all

    now i know how to send by pdf, here is the attachment
    pic18f26k20_porttest.PDF
    i used pbp v 2.6

    i used internal osc 64mhz or 4mhz
    no external capacitors on the osc pins,
    the same program that is programed into the chip ran before but now it does not ( on both pcb and breadboard)
    i attach the program that is slighly changed the pause statement:

    INCLUDE "h:\AllDigital.pbp"
    ASM
    __CONFIG _CONFIG1H, _FOSC_INTIO67_1H & _FCMEN_OFF_1H & _IESO_OFF_1H
    __CONFIG _CONFIG2H, _WDTEN_ON_2H & _WDTPS_512_2H
    __CONFIG _CONFIG3H, _CCP2MX_PORTC_3H & _PBADEN_OFF_3H & _LPT1OSC_OFF_3H & _HFOFST_ON_3H & _MCLRE_ON_3H
    __CONFIG _CONFIG4L, _STVREN_ON_4L & _LVP_OFF_4L & _XINST_OFF_4L
    ENDASM
    OSCCON = $70 '$70 Internal oscillator is set to 16MHz $62 ' 8mhz--- '; Primary Clock is selected as system clock.
    OSCTUNE = $40 'HFINTOSC selected; PLL enabled; Factory calibrated frequency
    define OSC 64
    ADCON0 = 0
    CM1CON0.7 = 0
    CM2CON0.7 = 0
    portb = 0
    latb = 0
    trisb = 0
    '------------------------------------------
    i var byte
    m var byte
    main_program:
    gosub blink 'call suroutin to blink a led
    GOTO main_program
    '==============================================
    blink:
    high portb '= $ff ' light the led for acertain amount of time
    for i = 0 to 100 'loop to maintain the led on
    FOR M = 0 TO 10
    pause 1
    NEXT
    NEXT
    low portb '= 0 'tuen off the led for certain amount of time
    for i = 0 to 50 'loop to maintain the led off
    FOR M = 0 TO 10
    pause 1
    NEXT
    NEXT
    return
    '-------------------------------------------
    end

  2. #2
    Join Date
    Apr 2008
    Posts
    85


    Did you find this post helpful? Yes | No

    Default Re: blink a single led

    i do not under stand configuration is old hat and
    internal osc can delete post?
    can you explain clearly,
    tks

  3. #3
    Join Date
    Mar 2003
    Location
    Commerce Michigan USA
    Posts
    1,166


    Did you find this post helpful? Yes | No

    Default Re: blink a single led

    Looking at the schematic, I believe the MCLR reset connection violates the Spec. The correct circuit can be found on page 53 of the processor spec. The power supply rise time needs to be within spec. or it will never reset properly.
    Dave Purola,
    N8NTA
    EN82fn

  4. #4
    Join Date
    Apr 2008
    Posts
    85


    Did you find this post helpful? Yes | No

    Default Re: blink a single led

    tks Dave
    i do not have 15k-40k resistor,however, i disable mclr in the conf: mclre_off_3h
    but nothing happens, i check the resistors tomorrow,

  5. #5
    Join Date
    May 2013
    Location
    australia
    Posts
    2,644


    Did you find this post helpful? Yes | No

    Default Re: blink a single led

    Your code has some issues


    Code:
    INCLUDE "h:\AllDigital.pbp"    why ?
     ASM
        __CONFIG    _CONFIG1H, _FOSC_INTIO67_1H & _FCMEN_OFF_1H & _IESO_OFF_1H
        __CONFIG    _CONFIG2H, _WDTEN_ON_2H & _WDTPS_512_2H
        __CONFIG    _CONFIG3H, _CCP2MX_PORTC_3H & _PBADEN_OFF_3H & _LPT1OSC_OFF_3H & _HFOFST_ON_3H & _MCLRE_ON_3H
        __CONFIG    _CONFIG4L, _STVREN_ON_4L & _LVP_OFF_4L & _XINST_OFF_4L
     ENDASM
     OSCCON  = $70 '$70 Internal oscillator is set to 16MHz $62 ' 8mhz---  '; Primary Clock is selected as system clock.
     OSCTUNE = $40 'HFINTOSC selected; PLL enabled; Factory calibrated frequency
     define OSC 64
     ADCON0 = 0                        why ?
     CM1CON0.7 = 0                   why ?
     CM2CON0.7 = 0                   why ?           
     portb = 0                            why ?
     latb  = 0                              why ?
     trisb = 0                     is this really what you want ?
     '------------------------------------------
    i var byte
       m var byte
       main_program: 
       gosub blink        'call suroutin to blink a led
     GOTO main_program 
     '==============================================  
     blink:
     high portb '= $ff ' light the led for acertain amount of time         this is not a legitimate use of HIGH  
     for i = 0 to 100     'loop to maintain the led on
        FOR M = 0 TO 10
            pause 1
        NEXT
     NEXT
     low portb '= 0     'tuen off the led for certain amount of time              this is not a legitimate use of LOW  
     for i = 0 to 50     'loop to maintain the led off
        FOR M = 0 TO 10
            pause 1
        NEXT
     NEXT
     return
     '-------------------------------------------
    end
    I can't verify your config settings as I no longer use that ancient old complier [you could at least update to 2.6c]

    assuming your config and osc settings are workable then this code is tested an works for me ,
    1k r in series with led, vdd 5v 4.7k pullup on mclr

    Code:
    ASM
    __CONFIG    _CONFIG1H, _FOSC_INTIO67_1H & _FCMEN_OFF_1H & _IESO_OFF_1H
        __CONFIG    _CONFIG2H, _WDTEN_ON_2H & _WDTPS_512_2H
        __CONFIG    _CONFIG3H, _CCP2MX_PORTC_3H & _PBADEN_OFF_3H & _LPT1OSC_OFF_3H & _HFOFST_ON_3H & _MCLRE_ON_3H
    __CONFIG    _CONFIG4L, _STVREN_ON_4L & _LVP_OFF_4L & _XINST_OFF_4L
     ENDASM
     OSCCON  = $70 '$70 Internal oscillator is set to 16MHz $62 ' 8mhz---  '; Primary Clock is selected as system clock.
     OSCTUNE = $40 'HFINTOSC selected; PLL enabled; Factory calibrated frequency
     define OSC 64 
    ANSELH = 0 
     
    
    trisb=%11111110
      
    pause 2000
       
    
     '------------------------------------------
     i var byte
     m var byte
     main_program: 
     gosub blink 'call subroutine to blink a led
     GOTO main_program 
     '============================================== 
     blink:
     LATB.0=1 ; light the led  on portb.0 for a certain amount of time
     for i = 0 to 100 'loop to maintain the led on
     FOR M = 0 TO 10
     pause 1
     NEXT
     NEXT
     
     LATB.0=0  'turn off the led for certain amount of time
     for i = 0 to 50 'loop to maintain the led off
     FOR M = 0 TO 10
     pause 1
     NEXT
     NEXT
     return
     '-------------------------------------------
     end
    Warning I'm not a teacher

  6. #6
    Join Date
    Apr 2008
    Posts
    85


    Did you find this post helpful? Yes | No

    Default Re: blink a single led

    HELLO rICHARD,

    Thk for ur reply,
    the code displayed there is for timer, interrupt, and digital conversion.
    that run well for several years.
    your code is also not run at all on my breadboard.
    the ANSELH is not used in my code due to the fact the PBADEN_OFF_3H is off.
    about the version of the pbp, it is not relevant to the fail i think so.
    1 think i pay attention to is the effect of charge accumulated on the breadboard (run @64mhz). but the pcb no charge on it..
    i replayed another small breadboard , but the situation has not been better.

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


    Did you find this post helpful? Yes | No

    Default Re: blink a single led

    Suspect your breadboard if it is older than 1 year, the sockets corrode and become insulators.

    define OSC 64 ' does NOT make the pic oscillate at 64 mhz, it simply adjusts PBP's timing to accomodate that speed, so if you are running at say 4mhz then whatever you expect to happen in 1 second will take 4/64 or 16 seconds to happen. I think your config will not allow 64mhz as you need PLL FOSC = HSPLL HS oscillator, PLL enabled (Clock Frequency = 4 x FOSC1)
    Last edited by Archangel; - 10th December 2016 at 07:03.
    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.

Similar Threads

  1. Single PIC to Blink 5 LEDs Independently?
    By RossWaddell in forum mel PIC BASIC Pro
    Replies: 68
    Last Post: - 18th July 2015, 16:56
  2. need led blink program
    By asifiqbal in forum General
    Replies: 6
    Last Post: - 4th March 2014, 11:26
  3. blink led 12f683
    By mel4853 in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 19th January 2010, 22:39
  4. Single digit 7 Seg LED clock - PIC16F88
    By thirsty in forum Code Examples
    Replies: 4
    Last Post: - 17th July 2009, 08:42
  5. 10f206 Blink led
    By Bonxy in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 10th November 2005, 20:01

Members who have read this thread : 0

You do not have permission to view the list of names.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts