Why Does My PIC18F4580 Microcontroller Show Errors in MPLAB?

  • Thread starter Thread starter memyself66
  • Start date Start date
  • Tags Tags
    Controller Micro
AI Thread Summary
The user is experiencing errors while running their PIC18F4580 microcontroller code in MPLAB for a detergent control system project. They provided a code snippet but did not specify the nature of the errors encountered. Other forum members are requesting more details about the specific errors and any troubleshooting steps already taken to assist in diagnosing the issue. Clarifying these points could lead to more targeted help in resolving the problems with the code.
memyself66
Messages
1
Reaction score
0
hello,

this is regarding my project which is detergent control system that need microcontroller 18f4580..but there some error when i run using MPLAB, I'm not sure what was that. can anybody help me,,


Code:
#include<p18f4580.inc>


ORG 0000H
GOTO MAIN

	ORG 0008H
	BTFSS PIR1,ADIF
	RETFIE
	GOTO AD_ISR

;-------ADC INTERRUPT

		ORG 0100H
MAIN	CLRF TRISC           ;SET OUTPUT PORT
		BSF TRISA,0          ;SET INPUT PORT(LDR)
		MOVLW 0X81
		MOVWF ADCON0
		MOVLW 0XCE
		MOVWF ADCON1
		MOVLW 0X3F
		MOVWF ADCON2
		BCF PIR1,ADIF        ;ADC INTERRUPT
		BSF PIE1,ADIE
		BSF INTCON,PEIE
		BSF INTCON,GIE
OVER 	CALL DELAY
		BSF ADCON0,GO
		BRA OVER

;INTERRUPT PROGRAM

AD_ISR	
		ORG 200H
		MOVFF ADRESL,PORTC
		MOVFF ADRESH,PORTD
		CALL MONITOR
		CALL DELAY_1S
		BCF PIR1,ADIF
		RETFIE
		END

MONITOR
		BTFSS PORTA,0        ;CHECK SENSOR AT RA0
		GOTO MED_MTR
		BSF PORTC,2          ;RC2 ON, LED RED ON
		BCF PORTC,3          ;RC3 OFF, LED YELLOW OFF
		BCF PORTC,4          ;RC4 OFF, LED GREEN OFF
		CALL DELAY_1S
		CALL DELAY_1S
		CALL DELAY_1S
		CALL DELAY_1S
		BSF PORTC,1          ;RC1 ON, MOTOR RUN
		CALL DELAY_1S
		CALL DELAY_1S
		CALL DELAY_1S
		CALL DELAY_1S
		CALL DELAY_1S
		CALL DELAY_1S
		CALL DELAY_1S
		CALL DELAY_1S
		CALL DELAY_1S
		CALL DELAY           ;DELAY 9.5s
		BCF PORTC,1          ;RC1 OFF, MOTOR STOP
		BSF PORTC,4          ;RC4 ON, LED GREEN ON
		BRA $                ;SYSTEM BUSY
		RETURN



MED_MTR
		BCF PORTC,2          ;RC2 OFF, LED RED OFF
		BSF PORTC,3          ;RC3 ON, LED YELLOW ON
		BCF PORTC,4          ;RC4 OFF, LED GREEN OFF
		CALL DELAY_1S
		CALL DELAY_1S
		CALL DELAY_1S
		CALL DELAY_1S
		BSF PORTC,1          ;RC1 ON, MOTOR RUN
		CALL DELAY_1S
		CALL DELAY_1S
		CALL DELAY_1S
		CALL DELAY           ;DELAY 3.5s
		BCF PORTC,1          ;RC1 OFF, MOTOR STOP
		BSF PORTC,4          ;RC4 ON, LED GREEN ON
		BRA $                ;SYSTEM BUSY
		RETURN

;RELAY 1S USING LOOP

DELAY_1S
		R2	EQU	0x2
		R3	EQU	0X3
		R4	EQU	0X4
		MOVLW D'20'          ;CHECK VALUE FOR 20MHZ Fosc
		MOVWF R4
BACK	MOVLW D'100'
		MOVWF R3
AGAIN	MOVLW D'250'
		MOVWF R2
HERE	NOP
		NOP
		DECF R2,F
		BNZ HERE
		DECF R3,F
		BNZ AGAIN
		DECF R4,F
		BNZ BACK
		RETURN


DELAY
		R5	EQU	0x5
		R6	EQU	0X6
		R7	EQU	0X7
		MOVLW D'10'          ;CHECK VALUE FOR 20MHZ Fosc
		MOVWF R4
L1		MOVLW D'100'
		MOVWF R3
L2		MOVLW D'250'
		MOVWF R2
L3		NOP
		NOP
		DECF R5,F
		BNZ L3
		DECF R6,F
		BNZ L2
		DECF R7,F
		BNZ L1
		RETURN



END

i attach the program also, please help me,
 

Attachments

Last edited by a moderator:
Physics news on Phys.org


memyself66 said:
hello,

this is regarding my project which is detergent control system that need microcontroller 18f4580..but there some error when i run using MPLAB, I'm not sure what was that. can anybody help me,,


Code:
#include<p18f4580.inc>


ORG 0000H
GOTO MAIN

	ORG 0008H
	BTFSS PIR1,ADIF
	RETFIE
	GOTO AD_ISR

;-------ADC INTERRUPT

		ORG 0100H
MAIN	CLRF TRISC           ;SET OUTPUT PORT
		BSF TRISA,0          ;SET INPUT PORT(LDR)
		MOVLW 0X81
		MOVWF ADCON0
		MOVLW 0XCE
		MOVWF ADCON1
		MOVLW 0X3F
		MOVWF ADCON2
		BCF PIR1,ADIF        ;ADC INTERRUPT
		BSF PIE1,ADIE
		BSF INTCON,PEIE
		BSF INTCON,GIE
OVER 	CALL DELAY
		BSF ADCON0,GO
		BRA OVER

;INTERRUPT PROGRAM

AD_ISR	
		ORG 200H
		MOVFF ADRESL,PORTC
		MOVFF ADRESH,PORTD
		CALL MONITOR
		CALL DELAY_1S
		BCF PIR1,ADIF
		RETFIE
		END

MONITOR
		BTFSS PORTA,0        ;CHECK SENSOR AT RA0
		GOTO MED_MTR
		BSF PORTC,2          ;RC2 ON, LED RED ON
		BCF PORTC,3          ;RC3 OFF, LED YELLOW OFF
		BCF PORTC,4          ;RC4 OFF, LED GREEN OFF
		CALL DELAY_1S
		CALL DELAY_1S
		CALL DELAY_1S
		CALL DELAY_1S
		BSF PORTC,1          ;RC1 ON, MOTOR RUN
		CALL DELAY_1S
		CALL DELAY_1S
		CALL DELAY_1S
		CALL DELAY_1S
		CALL DELAY_1S
		CALL DELAY_1S
		CALL DELAY_1S
		CALL DELAY_1S
		CALL DELAY_1S
		CALL DELAY           ;DELAY 9.5s
		BCF PORTC,1          ;RC1 OFF, MOTOR STOP
		BSF PORTC,4          ;RC4 ON, LED GREEN ON
		BRA $                ;SYSTEM BUSY
		RETURN



MED_MTR
		BCF PORTC,2          ;RC2 OFF, LED RED OFF
		BSF PORTC,3          ;RC3 ON, LED YELLOW ON
		BCF PORTC,4          ;RC4 OFF, LED GREEN OFF
		CALL DELAY_1S
		CALL DELAY_1S
		CALL DELAY_1S
		CALL DELAY_1S
		BSF PORTC,1          ;RC1 ON, MOTOR RUN
		CALL DELAY_1S
		CALL DELAY_1S
		CALL DELAY_1S
		CALL DELAY           ;DELAY 3.5s
		BCF PORTC,1          ;RC1 OFF, MOTOR STOP
		BSF PORTC,4          ;RC4 ON, LED GREEN ON
		BRA $                ;SYSTEM BUSY
		RETURN

;RELAY 1S USING LOOP

DELAY_1S
		R2	EQU	0x2
		R3	EQU	0X3
		R4	EQU	0X4
		MOVLW D'20'          ;CHECK VALUE FOR 20MHZ Fosc
		MOVWF R4
BACK	MOVLW D'100'
		MOVWF R3
AGAIN	MOVLW D'250'
		MOVWF R2
HERE	NOP
		NOP
		DECF R2,F
		BNZ HERE
		DECF R3,F
		BNZ AGAIN
		DECF R4,F
		BNZ BACK
		RETURN


DELAY
		R5	EQU	0x5
		R6	EQU	0X6
		R7	EQU	0X7
		MOVLW D'10'          ;CHECK VALUE FOR 20MHZ Fosc
		MOVWF R4
L1		MOVLW D'100'
		MOVWF R3
L2		MOVLW D'250'
		MOVWF R2
L3		NOP
		NOP
		DECF R5,F
		BNZ L3
		DECF R6,F
		BNZ L2
		DECF R7,F
		BNZ L1
		RETURN



END

i attach the program also, please help me,

What kind of errors? Can you give more details about the problem, and what you have done to try to figure it out?
 

Similar threads

Replies
2
Views
6K
Replies
2
Views
7K
Back
Top