Continue to Site

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.

  • 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.

Need urgent help with 18F2520 MCLR issue

Status
Not open for further replies.

mastero

Member
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
 
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
 
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
 
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 ...!
 
Code:
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
 
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
 
This is the generated configs from Oshonsoft IDE

Config bits

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:
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
 
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
 
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

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:
You will need to add the usual program Header at the start of the program listing.


this i dont understand

hi,
Post your FULL program code, I will try it on my MPLAB/OSH.

E.
 
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
 
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:
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top