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.

[SOLVED] PIC16F1783 RA6, RA7 port issue

Status
Not open for further replies.

dreamyboy_999

Member level 2
Joined
Mar 1, 2014
Messages
47
Helped
0
Reputation
0
Reaction score
0
Trophy points
6
Activity points
414
I am using PIC16F1783 and MikroC IDE. No matter what I set the port settings for RA6 and RA7 in the firmware (input, output, digital, analog, set to 1, set to zero, etc..), these two ports are constantly pulled up to 1.6 V (I am using a 3.3 V supply). This is not the case for other RA0-RA5 ports. They work according to the settings set in in the firmware. Any thoughts? Here goes the initialization part of my code:

Code:
ANSELA = 0x00;               //PORT A is digital
ANSELB = 0x00;               //PORT B is digital
TRISA = 0x00;                //PORT A is output
TRISB = 0x02;                //PORT B is output except RB1 = input
TRISC = 0b10000000;          //PORT C is output, except RC7=input (TX)
CCP1CON = 0x00;    //PWM disabled
PORTC = 0;
PORTA = 0;
PORTB = 0;
APFCON.SCKSEL = 1;
APFCON.SDISEL = 1 ;
WPUA = 0x00;
WPUB = 0x00;
FVRCON = 0b10000001;     // FVREN=1 ... FVRRDY=0 ... TSEN=0 ... TSRNG=0 ... CDAFVR=00 ... ADFVR=01
ADCON1 = 0b11010011;   // ADFM=1 ... ADCS=101 (Fosc/16) ... b3=0 ... ADNREF=0 ...ADPREF=1
ADCON2 = NEGNONE;
SetFVR(2);                  // FVR = 2048 mV for the ADC

// Comparators
C1ON_bit     = 0;      //disable comparators
C2ON_bit     = 0;      //disable comparator

// Initialize Timer and Interrupt Bits
//OSCCON     = 0b11111000;         // 32 MHz = 0b11111000;
OSCCON     = 0b01110010;         // 8 MHz = 0b01110010;
INTCON     = 0b11100111;         // GIE=1   ... PEIE=1   ... TMR0IE=1 ... INTE=0   ... IOCIE=0 ... TMR0IF=1 ... INTF=1 ... IOCIF=1
OPTION_REG = 0b10000111;         // WPUEN=1 ... INTEDG=0 ... TMR0CS=0 ... TMR0SE=0 ... PSA=0   ... PS=111 (1:256)
T1CON      = 0b00110000;         // TMR1CS=00 (Fosc/4) ... T1CKPS=11 (1:8) ... T1OSCEN=0 ... T1SYNC=0 ... x ... TMR1ON=0
T2CON      = 0b01111111;         // 0 ... T2OUTPS=1111 (1:16 postscale) ... TMR2ON=1 ... T2CKPS=11 (1:64 prescale)
PIE1       = 0b00110000;         // TMR1GIE=0 ... ADIE=0 ... RCIE=1 ... TXIE=1 ... SSPIE=0 ... CCP1IE=0 ... TMR2IE=0 ... TMR1IE=0
PIE2       = 0B00000000;         // OCFIE=0   ... C2IE=0 ... C1IE=0 ... EEIE=0 ... BCLIE=0 ... x        ... C3IE=0   ... CCP2IE=0
TMR1H      = 0;
TMR1L      = 0;
// Initialize UART Bits
//SPBRGL          = 68;      // 32MHz: 832 (9600 baud) ... 68 (115200 baud)
SPBRGL          = 16;          // 8MHz: 207 (9600 baud)  ...  16 (115200 baud)
SPBRGH          = 0;
BAUDCON         = 0b00001000;   // BRG16=1
TXSTA           = 0b00100100;   // TXEN=1  ... SYNC=0 ... BRGH=1
RCSTA           = 0b10010000;   // SPEN=1  ... CREN=1 ...
 
Last edited by a moderator:

Yes ... show the code, or at least the part that supposedly does what you said.

[EDIT]

Ok, you did in the meantime I replied this.
 

Yes ... show the code, or at least the part that supposedly does what you said.

a very simple test:

RA0_bit = 1;
delay_ms(5000);
RA0_bit = 0;

When I look at the RA0 port signal, it acts as described in the firmware.

- - - Updated - - -

Yes ... show the code, or at least the part that supposedly does what you said.

Another observation that these two ports are pulled to 1.6 V even when the microcontroller is in RESET.
 

Did you check if the bank selection are corrects ?
 

Did you check if the bank selection are corrects ?

by bank selection, you mean the register address for the port registers? So far I have been trusting the definition that MikroC uses by default for register addresses.

- - - Updated - - -

Yes ... show the code, or at least the part that supposedly does what you said.

[EDIT]

Ok, you did in the meantime I replied this.

Do you think this could be a hardware issue? As the ports are pulled to 1.6 V even when the microcontroller is in reset...The point is that I have three PIC controllers in my custom built board and these two ports are acting weird in all the three instances...
 

Do you have the CONFIG registers set so they are not being used as CLKIN and CLKOUT pins?
I don't use use MikroC but I think they are set outside of the main program. Also, check your programming tool is observing the config words defined in the IDE.

Brian.
 
Do you have the CONFIG registers set so they are not being used as CLKIN and CLKOUT pins?
I don't use use MikroC but I think they are set outside of the main program. Also, check your programming tool is observing the config words defined in the IDE.

Brian.

Modifying the CONFIG registers in project settings returned normal I/O functionality to these pins! Thanks!
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top