1. Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.
    Dismiss Notice

Need urgent help with 18F2520 MCLR issue

Discussion in 'Oshonsoft' started by mastero, Sep 30, 2012.

  1. mastero

    mastero Member

    Joined:
    Nov 27, 2011
    Messages:
    69
    Likes:
    1
    Hello All,

    I need to use the MCLR as input RE.3

    but no matter what fuse i set the MCLR is always ON.

    Hope someone can help or put some light on this issue.

    I am using Osho basic compiler and simulator....

    I have got my PCB printed so cant go back to the drawing board.

    Need that pin.

    CHIP is 18f2520

    Any help is good.

    Regards
    Mastero
     
  2. Ian Rogers

    Ian Rogers Super Moderator Most Helpful Member

    Joined:
    Mar 28, 2011
    Messages:
    9,310
    Likes:
    914
    Location:
    Rochdale UK
    On Friday I used Oshonsoft to program the pic18f4520 ( same config, bigger chip ) I too want the MCLRE internal, It worked fine... Are you sure you haven't the pic18f252 selected by mistake?
     
  3. mastero

    mastero Member

    Joined:
    Nov 27, 2011
    Messages:
    69
    Likes:
    1
    Hello Ian

    I just tried to program 18f4520 same issue MCLR not disabled.

    any idea.

    Could you post the 18f4520 code snip so i know what i am doing wrong
     
  4. dave

    Dave New Member

    Joined:
    Jan 12, 1997
    Messages:
    -
    Likes:
    0


     
  5. mastero

    mastero Member

    Joined:
    Nov 27, 2011
    Messages:
    69
    Likes:
    1

    In the PIC_Simulator microcontroller view the MCLR is in gray
     
  6. mastero

    mastero Member

    Joined:
    Nov 27, 2011
    Messages:
    69
    Likes:
    1
    Define CONFIG1L = 0x00
    Define CONFIG1H = 0x02
    Define CONFIG2L = 0x19
    Define CONFIG2H = 0x00
    Define CONFIG3L = 0x00
    Define CONFIG3H = 0x00
    Define CONFIG4L = 0x80
    Define CONFIG4H = 0x00
    Define CONFIG5L = 0x0f
    Define CONFIG5H = 0xc0
    Define CONFIG6L = 0x0f
    Define CONFIG6H = 0xe0
    Define CONFIG7L = 0x0f
    Define CONFIG7H = 0x40

    Define CLOCK_FREQUENCY = 4
    AllDigital

    TRISA = %00000000
    TRISB = %00000000
    TRISC = %11000000
    TRISD = %00000000
    TRISE = %00001000


    Symbol led = PORTC.4 'status LED
    Symbol inp = PORTE.3



    main:
    led = 0
    WaitMs 5
    Hseropen 9600


    start:
    led = 1

    menu:
    WaitMs 250

    If inp = 0 Then
    led = 1
    Else
    Toggle led
    Endif
    Goto menu
    End
     
  7. mastero

    mastero Member

    Joined:
    Nov 27, 2011
    Messages:
    69
    Likes:
    1
    Above is my simple code made for 18f4520 with 4mhz clock

    does the same thing MCLR is in gray in simulation

    any help is nice ...!
     
  8. Ian Rogers

    Ian Rogers Super Moderator Most Helpful Member

    Joined:
    Mar 28, 2011
    Messages:
    9,310
    Likes:
    914
    Location:
    Rochdale UK
    Code (text):
    Define CONFIG1L = 0x00
    Define CONFIG1H = 0x09
    Define CONFIG2L = 0x1a
    Define CONFIG2H = 0x00
    Define CONFIG3L = 0x00
    Define CONFIG3H = 0x03
    Define CONFIG4L = 0x80
    Define CONFIG4H = 0x00
    Define CONFIG5L = 0x0f
    Define CONFIG5H = 0xc0
    Define CONFIG6L = 0x0f
    Define CONFIG6H = 0xe0
    Define CONFIG7L = 0x0f
    Define CONFIG7H = 0x40
     
    This is the generated configs from Oshonsoft IDE

    Config bits
     
  9. mastero

    mastero Member

    Joined:
    Nov 27, 2011
    Messages:
    69
    Likes:
    1
    Define CONFIG1L = 0x00
    Define CONFIG1H = 0x09
    Define CONFIG2L = 0x1a
    Define CONFIG2H = 0x00
    Define CONFIG3L = 0x00
    Define CONFIG3H = 0x03
    Define CONFIG4L = 0x80
    Define CONFIG4H = 0x00
    Define CONFIG5L = 0x0f
    Define CONFIG5H = 0xc0
    Define CONFIG6L = 0x0f
    Define CONFIG6H = 0xe0
    Define CONFIG7L = 0x0f
    Define CONFIG7H = 0x40

    Config PORTC.4 = Output
    Config PORTE.3 = Input

    Symbol led = PORTC.4 'status LED
    Symbol inp = PORTE.3

    main:
    led = 0
    WaitMs 5

    start:
    led = 1

    menu:
    WaitMs 5

    If inp = 0 Then
    led = 1
    Else
    Toggle led
    Endif
    Goto menu
    End
     
  10. mastero

    mastero Member

    Joined:
    Nov 27, 2011
    Messages:
    69
    Likes:
    1
    Still no joy

    same thing in 18f2520 and 18f4520

    :(
     
  11. ericgibbs

    ericgibbs Well-Known Member Most Helpful Member

    Joined:
    Jan 4, 2007
    Messages:
    21,238
    Likes:
    645
    Location:
    Ex Yorks' Hants UK
    hi Ian,
    I ran this CONFIG for 18F2520 in OSH yesterday [chat] , OSH config window shows OK that MCLR is reset.

    This should show PORTE.3 on the micro controller view as an input pin, but its always shown as MCLR.???

    E.
     
    Last edited: Oct 1, 2012
  12. mastero

    mastero Member

    Joined:
    Nov 27, 2011
    Messages:
    69
    Likes:
    1
    Define CONFIG1L = 0x00
    Define CONFIG1H = 0x02
    Define CONFIG2L = 0x1a
    Define CONFIG2H = 0x00
    Define CONFIG3L = 0x00
    Define CONFIG3H = 0x03
    Define CONFIG4L = 0x80
    Define CONFIG4H = 0x00
    Define CONFIG5L = 0x0f
    Define CONFIG5H = 0xc0
    Define CONFIG6L = 0x0f
    Define CONFIG6H = 0xe0
    Define CONFIG7L = 0x0f
    Define CONFIG7H = 0x40

    Define LCD_BITS = 8 'allowed values are 4 and 8 - the number of data interface lines
    Define LCD_DREG = PORTB
    Define LCD_DBIT = 0 '0 or 4 for 4-bit interface, ignored for 8-bit interface
    Define LCD_RSREG = PORTD
    Define LCD_RSBIT = 1
    Define LCD_EREG = PORTD
    Define LCD_EBIT = 3
    Define LCD_RWREG = PORTD 'set to 0 if not used, 0 is default
    Define LCD_RWBIT = 2 'set to 0 if not used, 0 is default
    Define LCD_COMMANDUS = 2000 'delay after LCDCMDOUT, default value is 5000
    Define LCD_DATAUS = 50 'delay after LCDOUT, default value is 100
    Define LCD_INITMS = 2 'delay used by LCDINIT, default value is 100
    'the last three Define directives set the values suitable for simulation; they should be omitted for a real device

    Dim an0 As Word

    AllDigital 'configure all pins for digital use
    ADCON1 = 0x0e 'configure AN0 input for analog use
    Lcdinit 1 'initialize LCD module; cursor is blinking

    loop:
    Adcin 0, an0
    Lcdcmdout LcdClear 'clear LCD display
    Lcdout "Analog input AN0" 'text for the line 1
    Lcdcmdout LcdLine2Home 'set cursor at the beginning of line 2
    Lcdout "Value: ", #an0 'formatted text for line 2
    WaitMs 1 'larger value should be used in real device
    Goto loop 'loop forever
     
  13. mastero

    mastero Member

    Joined:
    Nov 27, 2011
    Messages:
    69
    Likes:
    1
    Ok tried the example in oshon

    MUC is 18F4520 @4MHZ

    Only thing i changed is the MCLR fuse to off

    But does not go off still shows gray in microcontroller view

    any idea ?? or ideas ??

    HELP required urgently please
     
  14. ericgibbs

    ericgibbs Well-Known Member Most Helpful Member

    Joined:
    Jan 4, 2007
    Messages:
    21,238
    Likes:
    645
    Location:
    Ex Yorks' Hants UK
    Morning mastero.
    Do you have the MPLAB from microchip in your PC.?

    If yes, compile the program in OSH, then use the MPALB Wizard to create a 18F2520 project, then copy the asm file created by OSH into the MPLAB editor window.

    You will need to add the usual program Header at the start of the program listing.

    Build the program in MPLAB, use the Config window options in MPLAB to set the CONFIG, rebuild.

    Once its assembles OK, you can load the Hex file into OSH and run it in simulation.

    Do you follow OK.

    E.

    If after using the MPLAB hex file in OSH , it still shows the MCLR greyed out, its an OSH bug report thats required.
     
    Last edited: Oct 1, 2012
  15. mastero

    mastero Member

    Joined:
    Nov 27, 2011
    Messages:
    69
    Likes:
    1
    I have MPlab never used it before will try
     
  16. mastero

    mastero Member

    Joined:
    Nov 27, 2011
    Messages:
    69
    Likes:
    1
    You will need to add the usual program Header at the start of the program listing.


    this i dont understand
     
  17. ericgibbs

    ericgibbs Well-Known Member Most Helpful Member

    Joined:
    Jan 4, 2007
    Messages:
    21,238
    Likes:
    645
    Location:
    Ex Yorks' Hants UK
    hi,
    Post your FULL program code, I will try it on my MPLAB/OSH.

    E.
     
  18. mastero

    mastero Member

    Joined:
    Nov 27, 2011
    Messages:
    69
    Likes:
    1
    tried no joy
     
  19. ericgibbs

    ericgibbs Well-Known Member Most Helpful Member

    Joined:
    Jan 4, 2007
    Messages:
    21,238
    Likes:
    645
    Location:
    Ex Yorks' Hants UK
    Do you want a second opinion or help, if so post your program and will try it.:rolleyes:
     
  20. mastero

    mastero Member

    Joined:
    Nov 27, 2011
    Messages:
    69
    Likes:
    1
    Made the hex from MPLAB laoded it in OShon but same the MCLR pin is showing gray

    the fuse is showing off in config bit
     
  21. mastero

    mastero Member

    Joined:
    Nov 27, 2011
    Messages:
    69
    Likes:
    1
    THIS IS MY CODE SNIP

    Define CONFIG1L = 0x00
    Define CONFIG1H = 0x02
    Define CONFIG2L = 0x1a
    Define CONFIG2H = 0x00
    Define CONFIG3L = 0x00
    Define CONFIG3H = 0x03
    Define CONFIG4L = 0x80
    Define CONFIG4H = 0x00
    Define CONFIG5L = 0x0f
    Define CONFIG5H = 0xc0
    Define CONFIG6L = 0x0f
    Define CONFIG6H = 0xe0
    Define CONFIG7L = 0x0f
    Define CONFIG7H = 0x40

    Config PORTC.4 = Output
    Config PORTC.3 = Input

    Symbol led = PORTC.4 'status LED
    Symbol inp = PORTC.3 'status LED

    main:
    led = 0
    WaitMs 5

    start:
    led = 1

    menu:
    WaitMs 5
    If inp = 0 Then
    led = 1
    Else
    Toggle led
    Endif
    Goto menu
    End
     
    Last edited: Oct 1, 2012

Share This Page