Problem With Input Port-F Pin4 on PIC18F6520

(instructions, reset, WDT, specifications...) PIC17Cxx, PIC18Fxxx

Problem With Input Port-F Pin4 on PIC18F6520

Postby disremy » Mon Jun 30, 2014 2:22 pm

I have a weird problem with the Pin Port-F pin4 (0x10) on PIC18F6520
Whatever the level (0 or 5v voltage) at the input
pin Port-F pin4, the state doesn't change in PortF register.
the bit b4 is always read as 0 .
I used several methods to read it, with Btfsc intruction
or with MOVF Portf,W and test bit b4 in wreg.
In TrisF the Pin is well declared as a input
The analog to digital converter is disabled, Full inputs in logic mode.
the comparator is also disabled.
I verified that all registers implicated are in the good state
with a ICD3 in Step by Step mode.
ADCON0,ADCON1,TRISF,PORTF,CMCON,CVRCON.
I also verified that tere is no short circuit on hardware.
If someone have an idea ?
Last edited by disremy on Wed Jul 02, 2014 10:00 am, edited 1 time in total.
disremy
 
Posts: 8
Joined: Mon Jun 30, 2014 2:09 pm
PIC experience: Professional 5+ years with MCHP products

Re: Problem With Input Port-F Pin4 on PIC18F6520

Postby jtemples » Mon Jun 30, 2014 6:58 pm

What value have you set for ADCON1?
jtemples
Verified identity
 
Posts: 195
Joined: Sun May 25, 2014 2:23 am
Location: The 805
PIC experience: Professional 5+ years with MCHP products

Re: Problem With Input Port-F Pin4 on PIC18F6520

Postby SLTom992 » Mon Jun 30, 2014 8:15 pm

jt must be correct. You have ADCON1 lower nibble set to less than 0x06. Since this is the DEFAULT on this register you have to set ADCON1 to 0x06 or higher.
SLTom992
 
Posts: 58
Joined: Tue Jun 10, 2014 8:59 pm
PIC experience: Professional 1+ years with MCHP products

Re: Problem With Input Port-F Pin4 on PIC18F6520

Postby ric » Mon Jun 30, 2014 11:41 pm

disremy wrote:The analog to digital converter is disabled.
Full inputs in logic mode.
the comparator in also idsabled.
I verified that all registers implicated are in the good state
with a ICD3 in mode Step by Step.
ADCON0,ADCON1,TRISF,PORTF,CMCON,CVRCON.
...

All this states that you THINK you have put the correct value into all of these registers.
As you still have a problem, it is a much better idea to show the actual values in the registers, and/or the code writing to them, so others can independently verify you have done it correctly.
Latest test project, an LED matrix display made from one reel of addressable LEDs. here
User avatar
ric
Verified identity
 
Posts: 659
Joined: Sat May 24, 2014 2:35 pm
Location: Melbourne, Australia
PIC experience: Professional 5+ years with MCHP products

Re: Problem With Input Port-F Pin4 on PIC18F6520

Postby disremy » Tue Jul 01, 2014 9:33 am

The code is a input driver witch collect the state of several pins on several ports
An extract of the code :
Code: Select all
PIN_FD_BK    EQU     2        ;
PIN_VARDEF  EQU     4        ;

Variables :

INPUTS2      EQU     0x017D    ; Recopie avec mise en forme des entrees
INP_AUX4    EQU     0             ; Set Si Entree Auxiliaire 4 Active Defaut VAR
INP_AUX5    EQU     1             ; Set Si Entree Auxiliaire 5 Active FeedBack


Code:
            MOVLW   00010100B       ;
            MOVWF   TRISF               ;
            CLRF       CMCON            ; Utile Sur les Pic18 A Partir de 40 Broches
            CLRF       CVRCON           ;
;
            MOVLW   0x0F               ; Added code to desactivate the AD
            MOVWF   ADCON1          ; usually not required
            CLRF       ADCON0          ;
            LFSR       1,INPUTS2       ;
            CLRF       INDR1             ;
            LFSR       0,INPUTS         ;
            CLRF       INDR0             ;
;
            BTFSS    PORTE,IN_TOR2      ; Recopie Entree TOR Aux 1
            BSF        INDR0 ,INP_AUX1    ; Le Contact doit etre ferme
;
            BTFSS    PORTE,IN_TOR1      ; Recopie Entree TOR Aux 3
            BSF        INDR0 ,INP_AUX2    ; Le Contact doit etre ferme

            MOVF    PORTF,W                  ;                                   Doesn't work
            BTFSC   WREG ,PIN_VARDEF   ; Recopie Entree PIN_VARDEF       -    -

       ;     BTFSC   PORTF,PIN_VARDEF  ; Recopie Entree PIN_VARDEF   Doesn't work
       ;     BTFSC   PORTE,IN_TOR1       ; Recopie Entree TOR Aux 1     Work Well on PORTE
            BSF        INDR1 ,INP_AUX4      ; Le Contact doit etre Ouvert
;
;
            BTFSC   PORTF,PIN_FD_BK    ; Recopie Entree TOR Aux 4  Work Well !!
            BSF       INDR1 ,INP_AUX5     ; Le Contact doit etre ferme
;
;
            MOVLW   00001011B          ; Added code to restore good state for AD
            MOVWF   ADCON1              ;
            MOVLW   00000001B          ;    
            MOVWF   ADCON0              ;
Attachments
code.txt
added "code" tags around the code.
(1.96 KiB) Downloaded 287 times
disremy
 
Posts: 8
Joined: Mon Jun 30, 2014 2:09 pm
PIC experience: Professional 5+ years with MCHP products

Re: Problem With Input Port-F Pin4 on PIC18F6520

Postby Ian.M » Tue Jul 01, 2014 10:57 am

Use the LATx registers for individual output pin manipulation!
Ian.M
Verified identity
 
Posts: 95
Joined: Wed May 28, 2014 12:47 am
PIC experience: Professional 1+ years with MCHP products

Re: Problem With Input Port-F Pin4 on PIC18F6520

Postby disremy » Tue Jul 01, 2014 2:00 pm

I know that but it is a input problem, not ouput
I always use LATx to ouptut and Portx to input !!!
disremy
 
Posts: 8
Joined: Mon Jun 30, 2014 2:09 pm
PIC experience: Professional 5+ years with MCHP products

Re: Problem With Input Port-F Pin4 on PIC18F6520

Postby Ian.M » Tue Jul 01, 2014 7:20 pm

Sorry for the brain-fart.

Are you able to try a different chip to eliminate the possibility of a bad pin maybe due to ESD damage? When you pull the pin high is it hi-z or does it take significant current. Does the pin work as an output?
Ian.M
Verified identity
 
Posts: 95
Joined: Wed May 28, 2014 12:47 am
PIC experience: Professional 1+ years with MCHP products

Re: Problem With Input Port-F Pin4 on PIC18F6520

Postby disremy » Wed Jul 02, 2014 8:51 am

Thanks,
I made the test and I have the same behavior on another pic18F6520.
For Esd is a good idea but, the PortF-pin4 is driven by the photo transistor of an optocoupler ...
Several input and output of portF are protected by optocouplers
All other pin of portF work well wathever input or ouput mode.
Last edited by disremy on Wed Jul 02, 2014 9:58 am, edited 2 times in total.
disremy
 
Posts: 8
Joined: Mon Jun 30, 2014 2:09 pm
PIC experience: Professional 5+ years with MCHP products

Re: Problem With Input Port-F Pin4 on PIC18F6520

Postby disremy » Wed Jul 02, 2014 9:41 am

The Phototransistor collector pin of the optocoupler is pull-up by a 22K resistor to ensure good voltage level on portf-pin4 (4,8V).
disremy
 
Posts: 8
Joined: Mon Jun 30, 2014 2:09 pm
PIC experience: Professional 5+ years with MCHP products

Next

Return to 16-Bit Core

Who is online

Users browsing this forum: No registered users and 12 guests

cron