18F2550 Blinking LED With Pickit 2


Closed Thread
Results 1 to 8 of 8
  1. #1
    Join Date
    Apr 2010
    Posts
    4

    Default 18F2550 Blinking LED With Pickit 2

    Hi.

    I'm trying to make a PIC 18F2550 blinks using pickit 2 and the internal oscillator. But it doesn't do it. Here is what I have tried.

    1. I have the following code.

    Code:
    OSCCON = $70            'Int CLK 8MHz
    OSCTUNE.6 = 1           'PLL 4x
    ADCON1= %00001111       '$0F = disable A/D converter
    
    TRISA = %00000000       'All pins are outputs
    TRISB = %00000000           
    TRISC = %00000000           
    
    DEFINE OSC 32            '4x 8MHz
    
    flip:
    PORTC.0 = 1             'Turn on LED
    PAUSE 500               'Delay for .5 seconds
    PORTC.0 = 0             'Turn off LED
    PAUSE 500
    GOTO flip
    
    END
    2. This is my configuration on 18F2550.INC file.

    Code:
            LIST
            LIST p = 18F2550, r = dec, w = -311, w = -230, f = inhx32
            INCLUDE "P18F2550.INC"	; MPASM  Header
            __CONFIG    _CONFIG1L, _PLLDIV_5_1L & _CPUDIV_OSC1_PLL2_1L & _USBDIV_2_1L
            __CONFIG    _CONFIG3H, _PBADEN_OFF_3H
            __CONFIG    _CONFIG4L, _LVP_OFF_4L & _XINST_OFF_4L & 0DFh
            
            __CONFIG    _CONFIG1H, _FOSC_INTOSCIO_EC_1H
            __CONFIG    _CONFIG2H, _WDT_OFF_2H & _WDTPS_512_2H
            
            NOLIST
    3. I supposed the circuit is correct, because it runs with the following assambler code using MPLAB.

    Code:
    ;_INTRC_OSC_NOCLKOUT
    
    #include <p18F2550.inc>
    
        cblock 0x20
    Delay1                   ; Define two file registers for the
    Delay2                   ; delay loop
         endc
          
         org 0
    Start:
    ;     bsf       STATUS,RP0          ; select Register Page 1
         bcf       TRISC,0             ; make IO Pin B.0 an output
    ;     bcf       STATUS,RP0          ; back to Register Page 0
    MainLoop:
         bsf       PORTC,0             ; turn on LED C0
    OndelayLoop:
         decfsz    Delay1,f            ; Waste time.  
         goto      OndelayLoop         ; The Inner loop takes 3 instructions per loop * 256 loopss = 768 instructions
         decfsz    Delay2,f            ; The outer loop takes and additional 3 instructions per lap * 256 loops
         goto      OndelayLoop         ; (768+3) * 256 = 197376 instructions / 1M instructions per second = 0.197 sec.
                                       ; call it a two-tenths of a second.
          
         bcf       PORTC,0             ; Turn off LED C0
    OffDelayLoop:
         decfsz    Delay1,f            ; same delay as above
         goto      OffDelayLoop
         decfsz    Delay2,f
         goto      OffDelayLoop
         goto      MainLoop            ; Do it again...
         end
    Can you help me? Thanks.

  2. #2
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    The configs
    Code:
            __CONFIG    _CONFIG1L, _PLLDIV_5_1L & _CPUDIV_OSC1_PLL2_1L & _USBDIV_2_1L
            __CONFIG    _CONFIG1H, _FOSC_INTOSCIO_EC_1H
            __CONFIG    _CONFIG2H, _WDT_ON_2H & _WDTPS_512_2H
            __CONFIG    _CONFIG3H, _PBADEN_OFF_3H
            __CONFIG    _CONFIG4L, _LVP_OFF_4L & _XINST_OFF_4L & 0DFh
    Top of code
    Code:
    OSCCON = %01110000
    DEFINE OSC 8
    just little changes...
    Dave
    Always wear safety glasses while programming.

  3. #3
    Join Date
    Apr 2010
    Posts
    4


    Did you find this post helpful? Yes | No

    Default Hello

    Thanks mackrackit, but unfortunately it doesn't work. I made the changes you recommended, but the PIC continues not working

  4. #4
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    How is the MCLR pin connected?

    If it is not connected to anything then change the 3H line to
    Code:
    __CONFIG    _CONFIG3H, _PBADEN_OFF_3H & _MCLRE_OFF_3H
    Dave
    Always wear safety glasses while programming.

  5. #5
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    I just tested this on a 4550 (I do not have a 2550) and it works as expected.
    Code:
    DEFINE OSC 8
    @ __CONFIG    _CONFIG1L, _PLLDIV_5_1L & _CPUDIV_OSC1_PLL2_1L & _USBDIV_2_1L
    @ __CONFIG    _CONFIG1H, _FOSC_INTOSCIO_EC_1H
    @ __CONFIG    _CONFIG2H, _WDT_ON_2H & _WDTPS_512_2H
    @ __CONFIG    _CONFIG3H, _PBADEN_OFF_3H & _MCLRE_OFF_3H
    @ __CONFIG    _CONFIG4L, _LVP_OFF_4L & _XINST_OFF_4L & 0DFh
    OSCCON = %01110000
    
        TRISD = %00000000
        TRISC = %00000000
        flip:
        HIGH PORTD.7
        PORTD.6 = 1             'Turn on LED
        PORTC.0 = 1
        PAUSE 500               'Delay for .5 seconds
        PORTD.6 = 0             'Turn off LED
        PORTC.0 = 0
        PAUSE 500
        GOTO flip
    Dave
    Always wear safety glasses while programming.

  6. #6
    Join Date
    Apr 2010
    Posts
    4


    Did you find this post helpful? Yes | No

    Default Mmm nop

    The MCLR pin is connected directly to the first pin of the Pickit 2.

    I tried changing that configuration, but nothing happened.

  7. #7
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    Might be a stupid question but are you compiling for the correct chip?
    Are you using MCS?
    Dave
    Always wear safety glasses while programming.

  8. #8
    Join Date
    Apr 2010
    Posts
    4


    Did you find this post helpful? Yes | No

    Default Yes

    Yes, 18F2550 is selected on the combo box.

    I'm using MicroCode Studio 3.0.0.5 and PICBASIC PRO 2.50B. When I compile, it uses the MPLAB assembler and it opens and closes a console window.

Members who have read this thread : 1

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