18f1320 I/O ports
Posted: Wed Feb 27, 2008 12:07 pm
after the helps from the form members, I am able to run ,and set my I/O ports in the 18f1320, I can control all the outputs, but my input cannot be read
BTFSS PORTA,0
GOTO START
BSF PORTB,0
as per the above code when I press the portA,0 switch I should get the output at the portB,0 but I am not getting.
BTFSC PORTA,0
GOTO START
BSF PORTB,0
as per the above code once download the program I am getting the output at the portB,0 becaus the portA,0 switch is not pressed, but once I press the portA,0 switch, there should not be any output at the portB,0 but still the output is there.
i cannot find out the problem, my codes are bellow please help me,
list p=18F1320
include <p18F1320.inc> ;IF we use this not need to declare port address
radix hex
;----------------------------------------------------------------------
; cpu equates (memory map)
Status equ 0xFD8
PORTA equ 0xF80 ; define the potA address
PORTB equ 0xF81 ;
TRISA equ 0xF92
TRISB equ 0xF93
ADCON0 EQU 0XFC2
ADCON1 EQU 0XFC1
LATA EQU 0XF89
LATB EQU 0XF8A
;----------------------------------------------------------------------
org 0x000
CLRF PORTA ;clearing the output
MOVLW 0X00
MOVWF ADCON0
MOVLW 0X7F ;configure the A/D
MOVWF ADCON1 ;for digital inputs
MOVLW 0xFF
MOVWF TRISA,0
;MOVLW 0xD0 ;values used to set the port
;MOVWF TRISA
;MOVWF LATA ;'11111111'
CLRF PORTB ;clearing the output
MOVLW 0X70 ;
MOVWF ADCON1 ;digital I/O pins
MOVLW 0x00
MOVWF TRISB,0
;MOVLW 0XCF ;values used to set the port
;MOVWF TRISB
;MOVWF LATB ;'00000000'
Start
BTFSS PORTA,0
;BTFSC PORTA,0
GOTO Start
BSF PORTB,0
goto Start
END
BTFSS PORTA,0
GOTO START
BSF PORTB,0
as per the above code when I press the portA,0 switch I should get the output at the portB,0 but I am not getting.
BTFSC PORTA,0
GOTO START
BSF PORTB,0
as per the above code once download the program I am getting the output at the portB,0 becaus the portA,0 switch is not pressed, but once I press the portA,0 switch, there should not be any output at the portB,0 but still the output is there.
i cannot find out the problem, my codes are bellow please help me,
list p=18F1320
include <p18F1320.inc> ;IF we use this not need to declare port address
radix hex
;----------------------------------------------------------------------
; cpu equates (memory map)
Status equ 0xFD8
PORTA equ 0xF80 ; define the potA address
PORTB equ 0xF81 ;
TRISA equ 0xF92
TRISB equ 0xF93
ADCON0 EQU 0XFC2
ADCON1 EQU 0XFC1
LATA EQU 0XF89
LATB EQU 0XF8A
;----------------------------------------------------------------------
org 0x000
CLRF PORTA ;clearing the output
MOVLW 0X00
MOVWF ADCON0
MOVLW 0X7F ;configure the A/D
MOVWF ADCON1 ;for digital inputs
MOVLW 0xFF
MOVWF TRISA,0
;MOVLW 0xD0 ;values used to set the port
;MOVWF TRISA
;MOVWF LATA ;'11111111'
CLRF PORTB ;clearing the output
MOVLW 0X70 ;
MOVWF ADCON1 ;digital I/O pins
MOVLW 0x00
MOVWF TRISB,0
;MOVLW 0XCF ;values used to set the port
;MOVWF TRISB
;MOVWF LATB ;'00000000'
Start
BTFSS PORTA,0
;BTFSC PORTA,0
GOTO Start
BSF PORTB,0
goto Start
END