Why Does My PIC18F4580 Microcontroller Show Errors in MPLAB?

In summary, the conversation is about a project for a detergent control system that uses a microcontroller 18f4580. The person is experiencing errors when running the program on MPLAB and is asking for help. The program includes an interrupt and delay function. They are not clear on what the errors are and are seeking assistance.
  • #1
memyself66
1
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

  • microc.txt
    2.3 KB · Views: 387
Last edited by a moderator:
Physics news on Phys.org
  • #2


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?
 

Related to Why Does My PIC18F4580 Microcontroller Show Errors in MPLAB?

1. What is a microcontroller?

A microcontroller is a small computer on a single integrated circuit that is designed to control specific functions of a larger system. It is often used in electronic devices to perform tasks such as data processing, controlling motors, and interfacing with sensors.

2. What is the 18f4580 microcontroller?

The 18f4580 microcontroller is a specific model of microcontroller developed by Microchip Technology. It is a 8-bit microcontroller with a wide range of features, including a high-performance RISC CPU, flash memory, and various communication interfaces.

3. What are the advantages of using a microcontroller 18f4580?

Some advantages of using the 18f4580 microcontroller include its low cost, low power consumption, and versatility. It also has a wide range of features and can be easily programmed for different applications.

4. How do I program the 18f4580 microcontroller?

The 18f4580 microcontroller can be programmed using a variety of programming languages, including C, BASIC, and assembler. Microchip provides a free Integrated Development Environment (IDE) called MPLAB for programming their microcontrollers.

5. What are some common uses for the 18f4580 microcontroller?

The 18f4580 microcontroller is commonly used in a variety of electronic devices, such as home appliances, security systems, and automotive systems. It is also popular in educational and hobbyist projects due to its low cost and ease of use.

Similar threads

  • Engineering and Comp Sci Homework Help
Replies
2
Views
6K
  • Engineering and Comp Sci Homework Help
Replies
2
Views
7K
  • Electrical Engineering
Replies
10
Views
3K
Back
Top