dreamyboy_999
Member level 2
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: