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

ericgibbs

Well-Known Member
Most Helpful Member
Eric please come on chat if you can ....
hi,
I have tried the asm file from OSH in MPLAB, also modified the CONFIG bits in MPLAB, I cannot make PORTE.3 an Input, it seems to be stuck as MCLR.

I suggest you contact microchip, they may have a fix.

E.
 

ericgibbs

Well-Known Member
Most Helpful Member
For the last hour I have searched the web for this problem, it appears that many users have problems.

Rechecked the 18F2520.inc files etc, and tried various fixes, no luck.

I will have to look further when I get more time, if you find a solution please let me know.:rolleyes:
 

mastero

Member
Sure ... and if you do please let me know...

I feel its the oshon bug gonna try to load it to the muc and try the hex received from MPlab
 

ericgibbs

Well-Known Member
Most Helpful Member
Sure ... and if you do please let me know...

I feel its the oshon bug gonna try to load it to the muc and try the hex received from MPlab
hi,
I have checked the OSH 18F2520 configuration file listing with MPLAB's include file listing, I cannot see a difference.

Also checked the actual Configuration bits in the assembled listing, it shows 0x7F at 3H location MCLR OFF.

E
 

Ian Rogers

User Extraordinaire
Forum Supporter
Most Helpful Member
I have also been looking into this.... As I said in a previous post... I use the pic18f4520 with Oshonsoft with NO issues at all MCLRE is working as an input.

MPLAB also configures it correctly..... I am going to try your code on MPLAB...


No Need... The problem is with Oshonsoft... If the config is set.. It works in the real world... It also works in ISIS.

I have YOUR code running with the inp button on RE3... This is an input pin only...
 
Last edited:

mastero

Member
Hi
I have edited the .cvg file in osho now I get the mclr off. But the microcontroller view shows mclr on
If u see there is config in the first couple of line.

What version ur using ian

I have tried my code on both 2520 and 4520

Both are giving same issue

Ian could u post the code which works please

M
 

mastero

Member
When i am doing the main program MPlab is giving errors loads of errors

:(


Error[118] I:\TEST\MPLAB\18F2520.ASM 162 : Overwriting previous address contents (0000)
Error[118] I:\TEST\MPLAB\18F2520.ASM 162 : Overwriting previous address contents (0001)
Error[113] I:\TEST\MPLAB\18F2520.ASM 574 : Symbol not previously defined (status)
Error[113] I:\TEST\MPLAB\18F2520.ASM 576 : Symbol not previously defined (spen)
Error[113] I:\TEST\MPLAB\18F2520.ASM 576 : Symbol not previously defined (rcsta)
Error[113] I:\TEST\MPLAB\18F2520.ASM 578 : Symbol not previously defined (rx9)
Error[113] I:\TEST\MPLAB\18F2520.ASM 578 : Symbol not previously defined (rcsta)
Error[113] I:\TEST\MPLAB\18F2520.ASM 580 : Symbol not previously defined (sren)
Error[113] I:\TEST\MPLAB\18F2520.ASM 580 : Symbol not previously defined (rcsta)
Error[113] I:\TEST\MPLAB\18F2520.ASM 582 : Symbol not previously defined (cren)
Error[113] I:\TEST\MPLAB\18F2520.ASM 582 : Symbol not previously defined (rcsta)
Error[113] I:\TEST\MPLAB\18F2520.ASM 584 : Symbol not previously defined (ferr)
Error[113] I:\TEST\MPLAB\18F2520.ASM 584 : Symbol not previously defined (rcsta)
Error[113] I:\TEST\MPLAB\18F2520.ASM 586 : Symbol not previously defined (rx9d)
Error[113] I:\TEST\MPLAB\18F2520.ASM 586 : Symbol not previously defined (rcsta)
Error[113] I:\TEST\MPLAB\18F2520.ASM 589 : Symbol not previously defined (pir1)
Error[113] I:\TEST\MPLAB\18F2520.ASM 601 : Symbol not previously defined (txreg)
Error[113] I:\TEST\MPLAB\18F2520.ASM 604 : Symbol not previously defined (pie1)
Error[113] I:\TEST\MPLAB\18F2520.ASM 10241 : Symbol not previously defined (oerr)
Error[113] I:\TEST\MPLAB\18F2520.ASM 10241 : Symbol not previously defined (rcsta)
Error[113] I:\TEST\MPLAB\18F2520.ASM 10245 : Symbol not previously defined (ferr)
Error[113] I:\TEST\MPLAB\18F2520.ASM 10245 : Symbol not previously defined (rcsta)
Error[113] I:\TEST\MPLAB\18F2520.ASM 10251 : Symbol not previously defined (rcif)
Error[113] I:\TEST\MPLAB\18F2520.ASM 10251 : Symbol not previously defined (pir1)
Error[113] I:\TEST\MPLAB\18F2520.ASM 10255 : Symbol not previously defined (gie)
Error[113] I:\TEST\MPLAB\18F2520.ASM 10255 : Symbol not previously defined (intcon)
Error[113] I:\TEST\MPLAB\18F2520.ASM 10257 : Symbol not previously defined (gie)
Error[113] I:\TEST\MPLAB\18F2520.ASM 10257 : Symbol not previously defined (intcon)
Error[113] I:\TEST\MPLAB\18F2520.ASM 10261 : Symbol not previously defined (rcreg)
Error[113] I:\TEST\MPLAB\18F2520.ASM 10263 : Symbol not previously defined (gie)
Error[113] I:\TEST\MPLAB\18F2520.ASM 10263 : Symbol not previously defined (intcon)
Error[113] I:\TEST\MPLAB\18F2520.ASM 10267 : Symbol not previously defined (gie)
Error[113] I:\TEST\MPLAB\18F2520.ASM 10267 : Symbol not previously defined (intcon)
Error[113] I:\TEST\MPLAB\18F2520.ASM 10273 : Symbol not previously defined (cren)
Error[113] I:\TEST\MPLAB\18F2520.ASM 10273 : Symbol not previously defined (rcsta)
Error[113] I:\TEST\MPLAB\18F2520.ASM 10275 : Symbol not previously defined (rcreg)
Error[113] I:\TEST\MPLAB\18F2520.ASM 10277 : Symbol not previously defined (rcreg)
Error[113] I:\TEST\MPLAB\18F2520.ASM 10279 : Symbol not previously defined (rcreg)
Error[113] I:\TEST\MPLAB\18F2520.ASM 10281 : Symbol not previously defined (cren)
Error[113] I:\TEST\MPLAB\18F2520.ASM 10281 : Symbol not previously defined (rcsta)
Error[113] I:\TEST\MPLAB\18F2520.ASM 10283 : Symbol not previously defined (gie)
Error[113] I:\TEST\MPLAB\18F2520.ASM 10283 : Symbol not previously defined (intcon)
Error[113] I:\TEST\MPLAB\18F2520.ASM 10287 : Symbol not previously defined (gie)
Error[113] I:\TEST\MPLAB\18F2520.ASM 10287 : Symbol not previously defined (intcon)
Error[113] I:\TEST\MPLAB\18F2520.ASM 10289 : Symbol not previously defined (gie)
Error[113] I:\TEST\MPLAB\18F2520.ASM 10289 : Symbol not previously defined (intcon)
Error[113] I:\TEST\MPLAB\18F2520.ASM 10293 : Symbol not previously defined (rcreg)
Error[113] I:\TEST\MPLAB\18F2520.ASM 10295 : Symbol not previously defined (gie)
Error[113] I:\TEST\MPLAB\18F2520.ASM 10295 : Symbol not previously defined (intcon)
 

Ian Rogers

User Extraordinaire
Forum Supporter
Most Helpful Member
You need to include the definition file "p16f628a.inc"... In the Oshonsoft IDE The menu bar contains "Options" Make sure the "Generate MPASMWIN compatible listing" is selected.
You should get a asm file that will build in MPLAB IDE.
 

Ian Rogers

User Extraordinaire
Forum Supporter
Most Helpful Member
Here's my listing... It assembles without warning / error

Code:
	list p=18f2520
	#include <p18f2520.inc>
	radix dec
; Compiled with: PIC18 Simulator IDE v2.81
; Microcontroller model: PIC18F2520
; Clock frequency: 20.0 MHz
;
;       The address of 'inp' (bit) (global) is 0xF82,4
;       The address of 'led' (bit) (global) is 0xF82,3
; Begin
R0L EQU 0x000
R0H EQU 0x001
R1L EQU 0x002
R1H EQU 0x003
R2L EQU 0x004
R2H EQU 0x005
R3L EQU 0x006
R3H EQU 0x007
R4L EQU 0x008
R4H EQU 0x009
R5L EQU 0x00A
R5H EQU 0x00B
R6L EQU 0x00C
R6H EQU 0x00D
R7L EQU 0x00E
R7H EQU 0x00F
R8L EQU 0x010
R8H EQU 0x011
R9L EQU 0x012
R9H EQU 0x013

	ORG 0x000000
	BSF RCON,IPEN
	BRA L0004
	ORG 0x000008
	RETFIE FAST
	ORG 0x000018
	RETFIE FAST
; Begin of program
L0004:
; 1: Define CONFIG1L = 0x00
; 2: Define CONFIG1H = 0x02
; 3: Define CONFIG2L = 0x1a
; 4: Define CONFIG2H = 0x00
; 5: Define CONFIG3L = 0x00
; 6: Define CONFIG3H = 0x03
; 7: Define CONFIG4L = 0x80
; 8: Define CONFIG4H = 0x00
; 9: Define CONFIG5L = 0x0f
; 10: Define CONFIG5H = 0xc0
; 11: Define CONFIG6L = 0x0f
; 12: Define CONFIG6H = 0xe0
; 13: Define CONFIG7L = 0x0f
; 14: Define CONFIG7H = 0x40
; 15: 
; 16: 
; 17: Config PORTC.4 = Input
	BSF TRISC,4
; 18: Config PORTC.3 = Output
	BCF TRISC,3
; 19: 
; 20: Symbol inp = PORTC.4  'status LED
; 21: Symbol led = PORTC.3  'status LED
; 22: 
; 23: main:
L0001:
; 24: led = 0
	BCF 0xF82,3
; 25: WaitMs 5
	MOVLW 0x05
	MOVWF R0L
	CLRF R0H
	RCALL W001
; 26: 
; 27: start:
L0002:
; 28: led = 1
	BSF 0xF82,3
; 29: 
; 30: menu:
L0003:
; 31: WaitMs 250
	MOVLW 0xFA
	MOVWF R0L
	CLRF R0H
	RCALL W001
; 32: If inp = 0 Then
	BTFSC 0xF82,4
	BRA L0005
; 33: led = 1
	BSF 0xF82,3
; 34: Else
	BRA L0006
L0005:
; 35: Toggle led
	BCF TRISC,3
	BTG LATC,3
; 36: Endif
L0006:
; 37: Goto menu
	BRA L0003
; 38: End
L0007	BRA L0007
; End of program
L0008	BRA L0008
; Waitms Routine
W001:	MOVF R0L,F
	BTFSC STATUS,Z
	BRA W002
	RCALL W003
	DECF R0L,F
	NOP
	NOP
	NOP
	NOP
	NOP
	BRA W001
W002:	MOVF R0H,F
	BTFSC STATUS,Z
	RETURN
	RCALL W003
	DECF R0H,F
	DECF R0L,F
	BRA W001
W003:	MOVLW 0x0C
	MOVWF R2H
W004:	DECFSZ R2H,F
	BRA W004
	NOP
	NOP
	MOVLW 0x62
	MOVWF R1L
W005:	DECFSZ R1L,F
	BRA W006
	RCALL W007
	RCALL W007
	NOP
	NOP
	RETURN
W006	RCALL W007
	BRA W005
W007:	MOVLW 0x0D
	MOVWF R2L
W008:	DECFSZ R2L,F
	BRA W008
	NOP
	RETURN
; Configuration bytes settings
	ORG 0x300000
	DW 0x0200
	DW 0x001A
	DW 0x0300
	DW 0x0080
	DW 0xC00F
	DW 0xE00F
	DW 0x400F
; End of listing
	END
 

mastero

Member
Hello ,

solved the issue by creating the asm in osho then using MPlab to create the hex. now RE.3 is active.

now i have a new problem :(

My program has a UART routine in ASM


ASM:ser_in: btfsc rcsta,oerr
ASM: goto overerror
ASM: btfsc rcsta,ferr
ASM: goto frameerror
ASM: andlw 0x00 'return 0 if no data
ASM: btfss pir1,rcif
ASM: goto end_call
ASM:uart_gotit: bcf intcon,gie 'clear gie before read
ASM: btfsc intcon,gie
ASM: goto uart_gotit
ASM: movf rcreg,w
ASM: bsf intcon,gie
ASM: goto end_call
ASM:eek:vererror: bcf intcon,gie 'turn gie off
ASM: btfsc INTCON,GIE
ASM: goto overerror
ASM: bcf rcsta,cren
ASM: movf rcreg,w 'flush fifo
ASM: movf rcreg,w
ASM: movf rcreg,w
ASM: bsf rcsta,cren 'turn cren on, clear oerr flag
ASM: bsf intcon,gie
ASM: goto ser_in
ASM:frameerror: bcf intcon,gie
ASM: btfsc intcon,gie
ASM: goto frameerror
ASM: movf rcreg,w
ASM: bsf intcon,gie
ASM: goto ser_in
ASM:end_call: movwf serdata

Had to replace it with

hserget serdata

doing so all the following errors went

Error[113] I:\TEST\NEW FOLDER\18F2520.ASM 577 : Symbol not previously defined (status)
Error[113] I:\TEST\NEW FOLDER\18F2520.ASM 579 : Symbol not previously defined (spen)
Error[113] I:\TEST\NEW FOLDER\18F2520.ASM 579 : Symbol not previously defined (rcsta)
Error[113] I:\TEST\NEW FOLDER\18F2520.ASM 581 : Symbol not previously defined (rx9)
Error[113] I:\TEST\NEW FOLDER\18F2520.ASM 581 : Symbol not previously defined (rcsta)
Error[113] I:\TEST\NEW FOLDER\18F2520.ASM 583 : Symbol not previously defined (sren)
Error[113] I:\TEST\NEW FOLDER\18F2520.ASM 583 : Symbol not previously defined (rcsta)
Error[113] I:\TEST\NEW FOLDER\18F2520.ASM 585 : Symbol not previously defined (cren)
Error[113] I:\TEST\NEW FOLDER\18F2520.ASM 585 : Symbol not previously defined (rcsta)
Error[113] I:\TEST\NEW FOLDER\18F2520.ASM 587 : Symbol not previously defined (ferr)
Error[113] I:\TEST\NEW FOLDER\18F2520.ASM 587 : Symbol not previously defined (rcsta)
Error[113] I:\TEST\NEW FOLDER\18F2520.ASM 589 : Symbol not previously defined (rx9d)
Error[113] I:\TEST\NEW FOLDER\18F2520.ASM 589 : Symbol not previously defined (rcsta)
Error[113] I:\TEST\NEW FOLDER\18F2520.ASM 592 : Symbol not previously defined (pir1)
Error[113] I:\TEST\NEW FOLDER\18F2520.ASM 604 : Symbol not previously defined (txreg)
Error[113] I:\TEST\NEW FOLDER\18F2520.ASM 607 : Symbol not previously defined (pie1)
Error[113] I:\TEST\NEW FOLDER\18F2520.ASM 10244 : Symbol not previously defined (oerr)
Error[113] I:\TEST\NEW FOLDER\18F2520.ASM 10244 : Symbol not previously defined (rcsta)
Error[113] I:\TEST\NEW FOLDER\18F2520.ASM 10248 : Symbol not previously defined (ferr)
Error[113] I:\TEST\NEW FOLDER\18F2520.ASM 10248 : Symbol not previously defined (rcsta)
Error[113] I:\TEST\NEW FOLDER\18F2520.ASM 10254 : Symbol not previously defined (rcif)
Error[113] I:\TEST\NEW FOLDER\18F2520.ASM 10254 : Symbol not previously defined (pir1)
Error[113] I:\TEST\NEW FOLDER\18F2520.ASM 10258 : Symbol not previously defined (gie)
Error[113] I:\TEST\NEW FOLDER\18F2520.ASM 10258 : Symbol not previously defined (intcon)
Error[113] I:\TEST\NEW FOLDER\18F2520.ASM 10260 : Symbol not previously defined (gie)
Error[113] I:\TEST\NEW FOLDER\18F2520.ASM 10260 : Symbol not previously defined (intcon)
Error[113] I:\TEST\NEW FOLDER\18F2520.ASM 10264 : Symbol not previously defined (rcreg)
Error[113] I:\TEST\NEW FOLDER\18F2520.ASM 10266 : Symbol not previously defined (gie)
Error[113] I:\TEST\NEW FOLDER\18F2520.ASM 10266 : Symbol not previously defined (intcon)
Error[113] I:\TEST\NEW FOLDER\18F2520.ASM 10270 : Symbol not previously defined (gie)
Error[113] I:\TEST\NEW FOLDER\18F2520.ASM 10270 : Symbol not previously defined (intcon)
Error[113] I:\TEST\NEW FOLDER\18F2520.ASM 10276 : Symbol not previously defined (cren)
Error[113] I:\TEST\NEW FOLDER\18F2520.ASM 10276 : Symbol not previously defined (rcsta)
Error[113] I:\TEST\NEW FOLDER\18F2520.ASM 10278 : Symbol not previously defined (rcreg)
Error[113] I:\TEST\NEW FOLDER\18F2520.ASM 10280 : Symbol not previously defined (rcreg)
Error[113] I:\TEST\NEW FOLDER\18F2520.ASM 10282 : Symbol not previously defined (rcreg)
Error[113] I:\TEST\NEW FOLDER\18F2520.ASM 10284 : Symbol not previously defined (cren)
Error[113] I:\TEST\NEW FOLDER\18F2520.ASM 10284 : Symbol not previously defined (rcsta)
Error[113] I:\TEST\NEW FOLDER\18F2520.ASM 10286 : Symbol not previously defined (gie)
Error[113] I:\TEST\NEW FOLDER\18F2520.ASM 10286 : Symbol not previously defined (intcon)
Error[113] I:\TEST\NEW FOLDER\18F2520.ASM 10290 : Symbol not previously defined (gie)
Error[113] I:\TEST\NEW FOLDER\18F2520.ASM 10290 : Symbol not previously defined (intcon)
Error[113] I:\TEST\NEW FOLDER\18F2520.ASM 10292 : Symbol not previously defined (gie)
Error[113] I:\TEST\NEW FOLDER\18F2520.ASM 10292 : Symbol not previously defined (intcon)
Error[113] I:\TEST\NEW FOLDER\18F2520.ASM 10296 : Symbol not previously defined (rcreg)
Error[113] I:\TEST\NEW FOLDER\18F2520.ASM 10298 : Symbol not previously defined (gie)
Error[113] I:\TEST\NEW FOLDER\18F2520.ASM 10298 : Symbol not previously defined (intcon)


Now the problem is the hserget does not read the data received .... ( i can see the data on hyper terminal)

any idea ?
 

mastero

Member
THANX A MILLION TO ALL .......

It worked.

Ian just for the record why asm does not like the variable as data changed it to dataa worked well ....?

M
 
Status
Not open for further replies.

EE World Online Articles

Loading

 
Top