- #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,,
i attach the program also, please help me,
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: