Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

input pin problem in pic24ep512gu814

Status
Not open for further replies.

anboli

Full Member level 2
Joined
Mar 9, 2012
Messages
144
Helped
4
Reputation
8
Reaction score
4
Trophy points
1,298
Activity points
2,512
hi,
im using CCS compiler and mplab8.85 tool and controller is 16bit.
i had configured 64pins as input in the IC and 48 pin as output. In that some of the input pins are working quite. but some of the following pin making trouble. its not configuring as input in the port but in directional register its changing.
working pins:
RJ4
RJ5
RJ6
RJ7
RG12
RE3
RE6
RJ8
RJ9
RJ10
RJ11
RC1
RJ12


not working pin:
RB3
RB5
RE9
RE8
RG9
RC4
RC3
RC2
RE7
RE5
RG15
RE1
RE2
RE4
RB0
RB1
RB2
RE0
RA7


these are all the pins getting trouble.
for example the pin RA7 maked as input by using its directional register as TRISA = 0x0603. but the bit RA7 is not getting high, its always in low condition.
what i have to do now? whether its having some other register to configure as input.
 

Hi,

Check the data sheet, think you will find many of those ports are mulit-functional and you need to set or change other parameters as well as just input/output; example Analogue or Digital.

Also check for any CONFIG parameters that affect the port pins.
 

Check data sheet if your port pins are available for accepting inputs.
Port will have different functionality, every port might not be open with all registers.
 

Hi anboli ,

those ports are mulit-functional like AN3/C2INA/VPIO/RP35/RB3 (Analog/digital/remappable pins etc.) Kindly go through datasheet again.

Best regards,
 

Hi anboli,

what did i notice was most of the pins you have used are analog channels.First and foremost,to use port pins for I/O functionality with digital modules the corresponding ANSELx bits must be cleared off.And disable the comparators if you aren't using.I/O pins that are shared with any analog input pin,are always analog pins by default after any Reset. Consequently, configuring a pin as an analog input pin, automatically disables the digital input pin buffer and any attempt to read the digital input level by reading PORTx or LATx will always return a ‘0’, regardless of the digital logic level on the pin.

good wishes..
 

mithun had a valid point, try disabling the comparators and using ADPCFG register configure as digital pins
 

this is my program, i cleared all the ANSELx registers which i had maked as input.


Code C - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
#include <24ep512gu814.h>
    #include "REGISTERS.h"
    #include "PORT_BIT.h"
 
    #use delay(clock=25M)
 
    void main()
    {
        TRISA   =   0X0603; // 0b00000110 00000011
        TRISB   =   0XFFD0;         //0XFFFF;
        TRISC   =   0X0002;         //0X001E;
        TRISD   =   0X0000;
        TRISE   =   0X0048;         //0X03FF;
        TRISF   =   0X3000;
        TRISG   =   0X11C0;         //0X93C0;
        TRISH   =   0X001D;
        TRISJ   =   0XFFF0;
        TRISK   =   0XE003;
 
        ANSELA  =   0X0683;
        ANSELB  =   0XFFFF;
        ANSELC  =   0X001E;
        ANSELD  =   0X0000;
        ANSELE  =   0X03FF;
        ANSELF  =   0X3000;
        ANSELG  =   0X93C0;
        ANSELH  =   0X001D;
        ANSELJ  =   0XFFF0;
        ANSELK  =   0XE003;
 
        PORTA   =   0X0683;
        PORTB   =   0XFFFF;
        PORTC   =   0X001E;
        PORTD   =   0X0000;
        PORTE   =   0X03FF;
        PORTF   =   0X3000;
        PORTG   =   0X93C0;
        PORTH   =   0X001D;
        PORTJ   =   0XFFF0;
        PORTK   =   0XE003;
        
        LATA    =   0X0683;
        LATB    =   0XFFFF;
        LATC    =   0X001E;
        LATD    =   0X0000;
        LATE    =   0X03FF;
        LATF    =   0X3000;
        LATG    =   0X93C0;
        LATH    =   0X001D;
        LATJ    =   0XFFF0;
        LATK    =   0XE003;
    
        while(1)
        {
            if(!RA7) RD1 = 1;       //PROB
            else RD1 = 0;
            if(!RE0) RJ2 = 1;       //PROB
            else RJ2 = 0;
            if(!RE1) RJ3 = 1;       //PROB
            else RJ3 = 0;
            if(!RE2) RD5 = 1;       //prob
            else RD5 = 0;
            if(RE4) RD7 = 1;        //prob
            else RD7 = 0;
            if(RG15) RC14 = 1;      //prob
            else RC14 = 0;
            if(RE5) RC13 = 1;       //prob
            else RC13 = 0;
            if(RE7) RH15 = 1;       //prob
            else RH15 = 0;
            if(RC2) RD9 = 1;        //prob
            else RD9 = 0;
            if(RC3) RD8 = 1;        //prob
            else RD8 = 0;
            if(RC4) RA15 = 1;       //prob
            else RA15 = 0;
            if(RG9) RA5 = 1;        //prob
            else RA5 = 0;
            if(RE8) RH11 = 1;       //prob
            else RH11 = 0;
            if(RE9) RH10 = 1;       //prob
            else RH10 = 0;
            if(RB5) RF8 = 1;        //prob
            else RF8 = 0;
            if(RB3) RF3 = 1;        //prob
            else RF3 = 0;
            if(RB2) RD15 = 1;       //prob
            else RD15 = 0;
            if(RB1) RD14 = 1;       //prob
            else RD14 = 0;
            if(RB0) RH7 = 1;        //prob
            else RH7 = 0;
        }
    }

 
Last edited by a moderator:

so did u get any output or still the problem exists ?

use code tags to put your program, so that it makes ease for other to read !

- - - Updated - - -

are you using each and every pin of your processor ?

Code:
PORTA = 0X0683;
PORTB = 0XFFFF;
PORTC = 0X001E;
PORTD = 0X0000;
PORTE = 0X03FF;
PORTF = 0X3000;
PORTG = 0X93C0;
PORTH = 0X001D;
PORTJ = 0XFFF0;
PORTK = 0XE003;

LATA = 0X0683;
LATB = 0XFFFF;
LATC = 0X001E;
LATD = 0X0000;
LATE = 0X03FF;
LATF = 0X3000;
LATG = 0X93C0;
LATH = 0X001D;
LATJ = 0XFFF0;
LATK = 0XE003;
 

yes im using all the IO pins, (122 I/O)..

this is my latest updation of my program..

Code:
	#include <24ep512gu814.h>
	#include "REGISTERS.h"
	#include "PORT_BIT.h"

	#use delay(clock=25M)

	void main()
	{
		OSCCON	=	0x2200;
		TRISA	=	0X0683;			// 0b00000110 00000011
		TRISB	= 	0XFFFF;			// OLD VALUE// 0XFFFF;  // NEW VALUE// 0XFFD0
		TRISC	=	0X001E;			// OLD VALUE// 0X001E;  // NEW VALUE// 0X0002
		TRISD	=	0X0000;
		TRISE	=	0X03FF;			// OLD VALUE// 0X03FF;  // NEW VALUE// 0X0048
		TRISF	=	0X3000;
		TRISG	=	0X93C0;			// OLD VALUE// 0X93C0;  // NEW VALUE// 0X11C0
		TRISH	=	0X001D;
		TRISJ	=	0XFFF0;
		TRISK	= 	0XE003;
	
		ANSELA	=	0X0683;
		ANSELB	= 	0XFFFF;
		ANSELC	=	0X001E;
		ANSELD	=	0X0000;
		ANSELE	=	0X03FF;
		ANSELF	=	0X3000;
		ANSELG	=	0X93C0;
		ANSELH	=	0X001D;
		ANSELJ	=	0XFFF0;
		ANSELK	= 	0XE003;
	
		AD1CSSH = 	0x0000;
		AD1CSSL = 	0x0000;

		CNPUA	= 	0X0683;
		CNPUB	= 	0XFFFF;
		CNPUC	= 	0X001E;
		CNPUD	= 	0X0000;
		CNPUE	= 	0X03FF;
		CNPUF	= 	0X3000;
		CNPUG	= 	0X93C0;
		CNPUH	= 	0X001D;
		CNPUJ	= 	0XFFF0;
		CNPUK	= 	0XE003;

		LATA	=	0X0683;
		LATB	= 	0XFFFF;
		LATC	=	0X001E;
		LATD	=	0X0000;
		LATE	=	0X03FF;
		LATF	=	0X3000;
		LATG	=	0X93C0;
		LATH	=	0X001D;
		LATJ	=	0XFFF0;
		LATK	= 	0XE003;

		PORTA	=	0X0683;
		PORTB	= 	0XFFFF;
		PORTC	=	0X001E;
		PORTD	=	0X0000;
		PORTE	=	0X03FF;
		PORTF	=	0X3000;
		PORTG	=	0X93C0;
		PORTH	=	0X001D;
		PORTJ	=	0XFFF0;
		PORTK	= 	0XE003;
		
				
		while(1)
		{
			if(!RH0) RD7 = 1;			
			else RD7 = 0;
			if(!RH2) RC14 = 1;		
			else RC14 = 0;
			if(!RH3) RC13 = 1;		
			else RC13 = 0;
			if(!RK15) RA5 = 1;		
			else RA5 = 0;
			if(!RK14) RH11 = 1;		
			else RH11 = 0;
			if(!RK13) RH10 = 1;		
			else RH10 = 0;
			if(!RA1) RF8 = 1;		
			else RF8 = 0;
			if(!RF13) RF3 = 1;		
			else RF3 = 0;
			if(!RF12) RD15 = 1;		
			else RD15 = 0;
			if(!RH4) RJ0 = 1;
			else RJ0 = 0;

		// following are INPUT PROBLEMS 
			if(!RB6) RD1 = 1;			
			else RD1 = 0;
			if(!RB7) RJ2 = 1;			
			else RJ2 = 0;
			if(!RA9) RJ3 = 1;			
			else RJ3 = 0;
			if(!RA10) RD5 = 1;			
			else RD5 = 0;
			if(!RB8) RH15 = 1;		
			else RH15 = 0;
			if(!RB9) RD9 = 1;		
			else RD9 = 0;
			if(!RB10) RD8 = 1;		
			else RD8 = 0;
			if(!RB11) RA15 = 1;		
			else RA15 = 0;
			if(!RB12) RD14 = 1;		
			else RD14 = 0;
			if(!RB13) RH7 = 1;		
			else RH7 = 0;
			if(!RB14) RD12 = 1;
			else RD12 = 0;
			if(!RB15) RD13 = 1;
			else RD13 = 0;	
			
		}
	}
 

program has simple loops and i guess you no problem with the code!

I cant say the reason try reading port pins like if(PORTBbits.RB6),
and even then if ports aren't reading, try checking with multi-meter if your pins are working on press of a particular switch !
 

program has simple loops and i guess you no problem with the code!

I cant say the reason try reading port pins like if(PORTBbits.RB6),
and even then if ports aren't reading, try checking with multi-meter if your pins are working on press of a particular switch !


yeah i checked the hardware setup, its working quite. no problem, while im pressing the key, its getting zero and while releasing the switch its getting 3.08v.

- - - Updated - - -

HERE IM UPDATING MY SIMULATION WINDOW WITH THE REGISTERS.

from that you could understand whats the problem im facing now.

i adding the image orderwise from the reset.

0.jpeg is the configuration settings.
1.jpeg is the after reset
2.jpeg is OSCCON register
3.jpeg is PMD4 register
4.jpeg is TRISA register
5.jpeg is TRISB register..

- - - Updated - - -
 

Attachments

  • 0.jpeg
    0.jpeg
    149.3 KB · Views: 49
  • 5.JPG
    5.JPG
    145.1 KB · Views: 53
  • 1.jpeg
    1.jpeg
    148.4 KB · Views: 45
  • 2.jpeg
    2.jpeg
    122.4 KB · Views: 41
  • 3.jpeg
    3.jpeg
    156.2 KB · Views: 41
  • 4.JPG
    4.JPG
    156.9 KB · Views: 48

i just updating my input output setup of this controller. but i cant able to draw for full IO's. i just checking all the IO's by a switch and LED.

- - - Updated - - -

i updated my sample hardware circuit for the switch configuration.
 

Attachments

  • switch circuit.jpeg
    switch circuit.jpeg
    74 KB · Views: 98
  • PIC24.gif
    PIC24.gif
    58.8 KB · Views: 53

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top