18F2550 and Blink Led


Closed Thread
Page 1 of 2 12 LastLast
Results 1 to 40 of 50
  1. #1
    Join Date
    May 2012
    Posts
    18

    Default 18F2550 and Blink Led

    Hello Everyone,

    I'm trying to configure a basic program into a 18F2550, but with no luck.

    I'm testing the code with a simulator, but nothing happens...

    Anyone could help?


    DEFINE OSC 8

    @ __CONFIG _CONFIG1L, _PLLDIV_2_1L & _CPUDIV_OSC1_PLL2_1L & _USBDIV_2_1L
    @ __CONFIG _CONFIG1H, _FOSC_HS_1H
    @ __CONFIG _CONFIG2H, _WDT_OFF_2H & _WDTPS_512_2H
    @ __CONFIG _CONFIG2L, _PWRT_OFF_2L & _VREGEN_OFF_2L
    @ __CONFIG _CONFIG3H, _MCLRE_ON_3H
    @ __CONFIG _CONFIG4L, _LVP_ON_4L & _XINST_ON_4L

    PORTA = %00000000 ' Turn off all PORTA
    PORTB = %00000000 ' Turn off all PORTB
    ADCON1 = %01111000
    ADCON2 = %10000111
    TRISA = %11100111
    TRISB = %11000011

    loop1:
    LATB.2 = 1
    pause 100
    LATB.2 = 0
    PAUSE 100
    goto loop1
    end


    Thanks,
    Nuno

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


    Did you find this post helpful? Yes | No

    Default Re: 18F2550 and Blink Led

    Try
    Code:
    @ __CONFIG   _CONFIG1L, _PLLDIV_1_1L & _CPUDIV_OSC1_PLL2_1L & _USBDIV_2_1L
    @ __CONFIG   _CONFIG1H, _FOSC_INTOSCIO_EC_1H
    Dave
    Always wear safety glasses while programming.

  3. #3
    Join Date
    May 2012
    Posts
    18


    Did you find this post helpful? Yes | No

    Default Re: 18F2550 and Blink Led

    Thanks mackrackit, I try it but the same result, the pins of the Pic doesn't change state. The oscilator is a 8MHz, MCSP 3.0.0.5 Pic Basic Pro 2.60A.

    Any idea??

    Thanks,
    Nuno

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


    Did you find this post helpful? Yes | No

    Default Re: 18F2550 and Blink Led

    The below works using the internal OSC for a test.
    ' PIC18F2550
    DEFINE OSC 8
    ASM
    __CONFIG _CONFIG1L, _PLLDIV_1_1L & _CPUDIV_OSC1_PLL2_1L & _USBDIV_2_1L
    __CONFIG _CONFIG1H, _FOSC_INTOSCIO_EC_1H
    __CONFIG _CONFIG2H, _WDT_OFF_2H & _WDTPS_512_2H
    __CONFIG _CONFIG3H, _PBADEN_OFF_3H & _MCLRE_OFF_3H
    __CONFIG _CONFIG4L, _LVP_OFF_4L
    ENDASM

    ADCON1 = %00001111
    CMCON = 7
    OSCCON = %01110000
    TRISB = %00000000
    START

    LATB.2 = 1
    PAUSE 250
    LATB.2 = 0
    PAUSE 250
    GOTO START
    Dave
    Always wear safety glasses while programming.

  5. #5
    Join Date
    May 2012
    Posts
    18


    Did you find this post helpful? Yes | No

    Default Re: 18F2550 and Blink Led

    Hello,

    Compiling it, gives me some Warnings "Found Directive in column 1.(_CONFIG), but it compile. At the oshon simulator, the same result, the pins of the microcontroller doesn't change at all...

    Thanks,
    Nuno

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


    Did you find this post helpful? Yes | No

    Default Re: 18F2550 and Blink Led

    I do not use simulators, I can not help you there.

    For the warning, SPACE the
    __CONFIG
    over by one.
    Dave
    Always wear safety glasses while programming.

  7. #7
    Join Date
    May 2012
    Posts
    18


    Did you find this post helpful? Yes | No

    Default Re: 18F2550 and Blink Led

    Yes, the warning disapears... Thanks

    I'll try to program the chip and test it.

    Thanks,
    Nuno

  8. #8
    Join Date
    May 2012
    Posts
    18


    Did you find this post helpful? Yes | No

    Default Re: 18F2550 and Blink Led

    Hello,

    I've tested with the Pic, but without luck, nothing happens...

    Are this configurations correct?

    Thanks,
    Nuno

    Name:  Compile_2.JPG
Views: 2841
Size:  22.2 KBName:  Compile_1.JPG
Views: 2425
Size:  22.8 KB

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


    Did you find this post helpful? Yes | No

    Default Re: 18F2550 and Blink Led

    The default location for PBP is
    c:\pbp

    But if it is compiling where it is...
    How did PBP get installed inside of MCS?
    Dave
    Always wear safety glasses while programming.

  10. #10
    Join Date
    May 2012
    Posts
    18


    Did you find this post helpful? Yes | No

    Default Re: 18F2550 and Blink Led

    Hello mackrackit,

    I don't know how pbp intalled there... i've intalled it a long time ago.

    I'm looking at the assembler code, and it loops at:

    CLRWDT --> Clear WTD
    BTFSS PIR1,RCIF,A --> Check if Receiving bits... but i don't have nothing in my code...
    BRA-3 --> Goto the CLRWDT again

    anyone understand it??

    Thanks,
    Nuno

  11. #11
    Join Date
    May 2012
    Posts
    18


    Did you find this post helpful? Yes | No

    Default Re: 18F2550 and Blink Led

    Another thing is in ASM file (after compile), it starts with:

    #define CODE_SIZE 8
    #define MCS_STEP 73H
    #define MCS_DUMP 64H
    #define MCS_HANDSHAKE 68H
    #define MCS_RESET 72H
    #define MCS_WRITE 77H
    #define HSER_TXSTA 36
    #define HSER_SPBRG

    In my program, i don't define nothing of this...

    Anyone understand it??

    Thanks,
    Nuno

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


    Did you find this post helpful? Yes | No

    Default Re: 18F2550 and Blink Led

    I think the best thing to do is un-install everything (PBP, MCS, MPLAB) and start over.
    Dave
    Always wear safety glasses while programming.

  13. #13
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default Re: 18F2550 and Blink Led

    MCS_STEP, MCS_DUMP, MCS_HANDSHAKE etc. come from the ICD (In-Circuit Debugger) in MicroCode Studio.

    They only get added when you click the "ICD Compile Program" button.

    When you compile a program for ICD, it will not run unless you are set up to use the ICD. (Serial connection to the PC).

    If you use the normal "Compile Program" or just "Compile" buttons, the program will probably run better.

    If you do not see a "Compile Program" or "Compile" button, right click on the toolbar and check the "Compile and Program" option.
    You can turn off the ICD toolbar so you don't get confused in the future.
    DT

  14. #14
    Join Date
    May 2012
    Posts
    18


    Did you find this post helpful? Yes | No

    Default Re: 18F2550 and Blink Led

    Hello,

    What a silly mistake... You are wright Darrel, i'm compiling always with the ICD Compile...

    Thanks for your help, it's solved.

    Thanks,
    Nuno

  15. #15
    Join Date
    Feb 2013
    Posts
    1,078


    Did you find this post helpful? Yes | No

    Default Re: 18F2550 and Blink Led

    I'm trying to just compile the code below:

    Code:
    ' PIC18F2550 
     DEFINE OSC 8 
     ADCON1 = %00001111
     CMCON = 7
     OSCCON = %01110000
     TRISB = %00000000
     START
    
     LATB.2 = 1
     PAUSE 250
     LATB.2 = 0
     PAUSE 250
     GOTO START
    It gives Block overflow for #ENDCONFIG.

    MCU is 18F2550

    What might be the reason?

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


    Did you find this post helpful? Yes | No

    Default Re: 18F2550 and Blink Led

    START label missing colon?

    Robert

  17. #17
    Join Date
    Feb 2013
    Posts
    1,078


    Did you find this post helpful? Yes | No

    Default Re: 18F2550 and Blink Led

    It does not helps. Still:

    [ERROR] program files (89) : Block overflow for #ENDCONFIG

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


    Did you find this post helpful? Yes | No

    Default Re: 18F2550 and Blink Led

    Post your whole cide and PBP version.
    Dave
    Always wear safety glasses while programming.

  19. #19
    Join Date
    Feb 2013
    Posts
    1,078


    Did you find this post helpful? Yes | No

    Default Re: 18F2550 and Blink Led

    Whole code is already posted, PBP is PBP3.

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


    Did you find this post helpful? Yes | No

    Default Re: 18F2550 and Blink Led

    Place this at the top of your cade and see what happens.
    #CONFIG
    __CONFIG _CONFIG1L, _PLLDIV_5_1L & _CPUDIV_OSC1_PLL2_1L & _USBDIV_2_1L
    __CONFIG _CONFIG1H, _FOSC_HSPLL_HS_1H & _FCMEN_OFF_1H & _IESO_OFF_1H
    __CONFIG _CONFIG2L, _PWRT_OFF_2L & _BOR_ON_2L & _BORV_3_2L & _VREGEN_ON_2L
    __CONFIG _CONFIG2H, _WDT_ON_2H & _WDTPS_512_2H
    __CONFIG _CONFIG3H, _CCP2MX_ON_3H & _PBADEN_OFF_3H & _LPT1OSC_OFF_3H & _MCLRE_ON_3H
    __CONFIG _CONFIG4L, _STVREN_ON_4L & _LVP_OFF_4L & _XINST_OFF_4L
    #ENDCONFIG
    Dave
    Always wear safety glasses while programming.

  21. #21
    Join Date
    Feb 2013
    Posts
    1,078


    Did you find this post helpful? Yes | No

    Default Re: 18F2550 and Blink Led

    Absolutely the same. Does it compiles for you?

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


    Did you find this post helpful? Yes | No

    Default Re: 18F2550 and Blink Led

    This is what I tested.
    Changed the config to internal though..
    Compiles fine.

    Code:
    #CONFIG
        __CONFIG _CONFIG1L, _PLLDIV_5_1L & _CPUDIV_OSC1_PLL2_1L & _USBDIV_2_1L
        __CONFIG _CONFIG1H, _FOSC_INTOSC_HS_1H & _FCMEN_OFF_1H & _IESO_OFF_1H
        __CONFIG _CONFIG2L, _PWRT_OFF_2L & _BOR_ON_2L & _BORV_3_2L & _VREGEN_ON_2L
        __CONFIG _CONFIG2H, _WDT_ON_2H & _WDTPS_512_2H
        __CONFIG _CONFIG3H, _CCP2MX_ON_3H & _PBADEN_OFF_3H & _LPT1OSC_OFF_3H & _MCLRE_ON_3H
        __CONFIG _CONFIG4L, _STVREN_ON_4L & _LVP_OFF_4L & _XINST_OFF_4L
    #ENDCONFIG
    
     DEFINE OSC 8 
     ADCON1 = %00001111
     CMCON = 7
     OSCCON = %01110000
     TRISB = %00000000
     
     START:
     LATB.2 = 1
     PAUSE 250
     LATB.2 = 0
     PAUSE 250
     GOTO START
    Dave
    Always wear safety glasses while programming.

  23. #23
    Join Date
    Feb 2013
    Posts
    1,078


    Did you find this post helpful? Yes | No

    Default Re: 18F2550 and Blink Led

    Strange, gives the same error here, might I need to install update or something similar?

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


    Did you find this post helpful? Yes | No

    Default Re: 18F2550 and Blink Led

    This is the best I can find that sorta refers to your problem
    http://support.melabs.com/threads/54...config-length?
    but I do not think it applies.

    Maybe try re-installing PBP3? Maybe it became corrupt ?
    Dave
    Always wear safety glasses while programming.

  25. #25
    Join Date
    Feb 2013
    Posts
    1,078


    Did you find this post helpful? Yes | No

    Default Re: 18F2550 and Blink Led

    Removed PBP, removed mplab and all associated apps, downloaded fresh copy of PBP, installed, still same error.

  26. #26
    Join Date
    Feb 2013
    Posts
    1,078


    Did you find this post helpful? Yes | No

    Default Re: 18F2550 and Blink Led

    Tried to follow this method:

    http://melabs.com/support/mplab.htm

    This time I get: Whitelist: Processor 18F2550 disabled in this version of PBP.
    To obtain additional device support, visit melabs.com.*

    Edition is student edition and 18F2550 is definitely included.

  27. #27
    Join Date
    Feb 2013
    Posts
    1,078


    Did you find this post helpful? Yes | No

    Default Re: 18F2550 and Blink Led

    Restarted the PC, and now compile trough MPLAB works fine, but it is not handy to do so.

  28. #28
    Join Date
    Feb 2013
    Posts
    1,078


    Did you find this post helpful? Yes | No

    Default Re: 18F2550 and Blink Led

    Figured out. Access restriction rules were causing the problems. Disabled UAC and it now works just fine!

  29. #29
    Join Date
    Mar 2008
    Posts
    59


    Did you find this post helpful? Yes | No

    Default Re: 18F2550 and Blink Led

    No blinky what am I doing wrong? The below config come from meconfig.exe.


    ;----[18F2550 Hardware Configuration]-------------------------------------------
    #CONFIG
    CONFIG PLLDIV = 5 ; Divide by 5 (20 MHz oscillator input)
    CONFIG CPUDIV = OSC1_PLL2 ; [Primary Oscillator Src: /1][96 MHz PLL Src: /2]
    CONFIG USBDIV = 2 ; USB clock source comes from the 96 MHz PLL divided by 2
    CONFIG FOSC = INTOSCIO_EC ; Internal oscillator, port function on RA6, EC used by USB (INTIO)
    CONFIG FCMEN = OFF ; Fail-Safe Clock Monitor disabled
    CONFIG IESO = OFF ; Oscillator Switchover mode disabled
    CONFIG PWRT = OFF ; PWRT disabled
    CONFIG BOR = ON ; Brown-out Reset enabled in hardware only (SBOREN is disabled)
    CONFIG BORV = 3 ; Minimum setting
    CONFIG VREGEN = ON ; USB voltage regulator enabled
    CONFIG WDT = ON ; WDT enabled
    CONFIG WDTPS = 512 ; 1:512
    CONFIG CCP2MX = OFF ; CCP2 input/output is multiplexed with RB3
    CONFIG PBADEN = OFF ; PORTB<4:0> pins are configured as digital I/O on Reset
    CONFIG LPT1OSC = OFF ; Timer1 configured for higher power operation
    CONFIG MCLRE = OFF ; RE3 input pin enabled; MCLR pin disabled
    CONFIG STVREN = ON ; Stack full/underflow will cause Reset
    CONFIG LVP = OFF ; Single-Supply ICSP disabled
    CONFIG XINST = OFF ; Instruction set extension and Indexed Addressing mode disabled (Legacy mode)
    CONFIG DEBUG = OFF ; Background debugger disabled, RB6 and RB7 configured as general purpose I/O pins
    CONFIG CP0 = OFF ; Block 0 (000800-001FFFh) is not code-protected
    CONFIG CP1 = OFF ; Block 1 (002000-003FFFh) is not code-protected
    CONFIG CP2 = OFF ; Block 2 (004000-005FFFh) is not code-protected
    CONFIG CP3 = OFF ; Block 3 (006000-007FFFh) is not code-protected
    CONFIG CPB = OFF ; Boot block (000000-0007FFh) is not code-protected
    CONFIG CPD = OFF ; Data EEPROM is not code-protected
    CONFIG WRT0 = OFF ; Block 0 (000800-001FFFh) is not write-protected
    CONFIG WRT1 = OFF ; Block 1 (002000-003FFFh) is not write-protected
    CONFIG WRT2 = OFF ; Block 2 (004000-005FFFh) is not write-protected
    CONFIG WRT3 = OFF ; Block 3 (006000-007FFFh) is not write-protected
    CONFIG WRTC = OFF ; Configuration registers (300000-3000FFh) are not write-protected
    CONFIG WRTB = OFF ; Boot block (000000-0007FFh) is not write-protected
    CONFIG WRTD = OFF ; Data EEPROM is not write-protected
    CONFIG EBTR0 = OFF ; Block 0 (000800-001FFFh) is not protected from table reads executed in other blocks
    CONFIG EBTR1 = OFF ; Block 1 (002000-003FFFh) is not protected from table reads executed in other blocks
    CONFIG EBTR2 = OFF ; Block 2 (004000-005FFFh) is not protected from table reads executed in other blocks
    CONFIG EBTR3 = OFF ; Block 3 (006000-007FFFh) is not protected from table reads executed in other blocks
    CONFIG EBTRB = OFF ; Boot block (000000-0007FFh) is not protected from table reads executed in other blocks
    #ENDCONFIG




    ADCON1 = %00001111
    CMCON = 7
    OSCCON = %01110000
    TRISB = %00000000
    OVER:

    low portb.0
    PAUSE 200
    high portb.0
    PAUSE 200
    GOTO OVER
    Last edited by n0yox; - 24th February 2018 at 04:20.

  30. #30
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,516


    Did you find this post helpful? Yes | No

    Default Re: 18F2550 and Blink Led

    The oscillator block on the USB equipped devices are a bit complicated.
    It looks to me as if you're trying to run off of the internal oscillator at 8MHz (judging by OSCCON setting INTOSC to 8MHz) yet the two least significant bits of OSCCON selects the primary oscillator - where you may or may not have a x-tal connected (you don't tell us anything about your hardware setup)?

    And you have not told the compiler what frequency you're aiming to run at.

    So, we need a bit more detail regarding what you're trying to do exactly.

    /Henrik.

  31. #31
    Join Date
    Mar 2008
    Posts
    59


    Did you find this post helpful? Yes | No

    Default Re: 18F2550 and Blink Led

    Thank you for your reply. You are right I am trying to use the internal oscillator and have no idea how to setup the oscillator section. I do not plan to use any of the special features “usb ” of this processor. I did notice my mistake late last night and fixed these lines,
    CONFIG FOSC = INTOSC_XT ; Internal oscillator, XT used by USB (INTXT)
    CONFIG MCLRE = OFF ; RE3 input pin enabled; MCLR pin disabled

    I am blinking now but have no idea how to set up the rest of the configuration. I am using the 18f2550 in place of a 16f648a to acquire more code space. I need all of my IOs to be digital with int.pullups on the top 4 of PORTB “4-7”. The datasheet is a 426 page fun read to say the least. Any help you offer will be appreciated.
    Thank You,

  32. #32


    Did you find this post helpful? Yes | No

    Default Re: 18F2550 and Blink Led

    The config you have seems fine but unless you want to use the watchdog turn WDT off and you can turb VREGEN off as you're not using USB. One question though, if you aren't using USB, why not use a device similar to 2550 but with additional features and more memory eg 18F25K22?
    George

  33. #33
    Join Date
    Mar 2008
    Posts
    59


    Did you find this post helpful? Yes | No

    Default Re: 18F2550 and Blink Led

    I was not aware of the 18F25K22. I should have asked for advice before I made the change. Sometimes selecting a new device can be very confusing. I will look at the data sheet for the 18F25K22 , do you have any other suggestions for a 16f648a substitute with more memory. I don’t really need the extra I/O’s just more code space.
    Thank you very much!

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


    Did you find this post helpful? Yes | No

    Default Re: 18F2550 and Blink Led

    If you are looking for a direct replacement I would suggest the 16F1847. Faster and twice the memory.
    Dave Purola,
    N8NTA
    EN82fn

  35. #35
    Join Date
    Mar 2008
    Posts
    59


    Did you find this post helpful? Yes | No

    Default Re: 18F2550 and Blink Led

    Thank you, I will make an order on Monday. I should have asked before I started this project.
    I have tried to use the pic comparison page with some luck http://www.microchip.com/maps/microcontroller.aspx
    Melabs once had a very simple chart that compared many of the most common controller however they deleted that page.

    I have one more question about the 18f2550 can anyone tell me how to turn on the weak pullups on the top 4 of PORTB “4-7”.
    Last edited by n0yox; - 24th February 2018 at 22:21.

  36. #36
    Join Date
    Mar 2008
    Posts
    59


    Did you find this post helpful? Yes | No

    Default Re: 18F2550 and Blink Led

    Is this close?
    INTCON2 = %00000000 ' makes all of portb have WPU ? INTCON2<7> 'page 116
    TRISB = %00001111 'B. 0:3 are now outputs WPU is now off?
    Last edited by n0yox; - 24th February 2018 at 23:12.

  37. #37
    Join Date
    Aug 2011
    Posts
    408


    Did you find this post helpful? Yes | No

    Default Re: 18F2550 and Blink Led

    To enable the pullups on PORTB just clear the RPBU bit in INTCON2 using INTCON2.7 = 0. It's an all or nothing thing on that chip... you can't set them individually.

    TRISB = %00001111 'B. 0:3 are now outputs WPU is now off?
    The comment doesn't match the setting, but to set PORTB 7:4 to inputs and the others (3:0) to outputs you'd use
    TRISB = %11110000

    The WPU is only enabled when the pin is set to input mode (TRIS bit = 1). It's disabled when the pin is an output (TRIS bit = 0)

  38. #38
    Join Date
    Mar 2008
    Posts
    59


    Did you find this post helpful? Yes | No

    Default Re: 18F2550 and Blink Led

    What I was attempting to say with that comment was that by using TRISB = %00001111 after the line containing INTCON2.7 = 0 you would set the bottom 4 bits to outputs causing those 4 bits to no longer have WPU , Maybe I have this backward and it should be TRISB = %11110000 Is this also wrong? As it turns out I need all 8 ports to have WPU’s so I will not be using that line. However for future use I would like to know the correct usage?
    Thank you so much!

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


    Did you find this post helpful? Yes | No

    Default Re: 18F2550 and Blink Led

    Try longer pauses.

  40. #40
    Join Date
    May 2013
    Location
    australia
    Posts
    2,381


    Did you find this post helpful? Yes | No

    Default Re: 18F2550 and Blink Led

    Is this also wrong?
    yes its wrong , if you read the datasheet its wpu for all pins that are inputs or no pins have wpu on that port

    Each of the PORTB pins has a weak internal pull-up. A
    single control bit can turn on all the pull-ups. This is
    performed by clearing bit, RBPU (INTCON2<7>). The
    weak pull-up is automatically turned off when the port
    pin is configured as an output. The pull-ups are
    disabled on a Power-on Reset.
    Warning I'm not a teacher

Members who have read this thread : 5

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