moahrs
Junior Member level 2
Hi all.
I have a big problem. I am a projet school using 18F2550, but a few days, I can't do works the pin RA2 how input digital.
I always read "0" in pin RA2. I put "1" in pin RA2, and still reading "0"....
All other pin was working fine, no trobles, but this pin dont works. I need to believe that the pin was working, but I am doing any worng in program.
Below, the initial configuration in my program.
Ty if any1 can helpme. I am using mplab and c18 compiler. I am brazilian, then some comments in program still in portuguese.
I have a big problem. I am a projet school using 18F2550, but a few days, I can't do works the pin RA2 how input digital.
I always read "0" in pin RA2. I put "1" in pin RA2, and still reading "0"....
All other pin was working fine, no trobles, but this pin dont works. I need to believe that the pin was working, but I am doing any worng in program.
Below, the initial configuration in my program.
Ty if any1 can helpme. I am using mplab and c18 compiler. I am brazilian, then some comments in program still in portuguese.
Code:
#define MINOR_VERSION 0x00
#define MAJOR_VERSION 0x01
#define OUT_CTRLWAIT LATAbits.LATA4
#define OUT_INTZ80 LATAbits.LATA5
#define OUT_SDA LATBbits.LATB0
#define OUT_SDL LATBbits.LATB1
#define OUT_TSTR LATAbits.LATA0
#define OUT_TSTY LATAbits.LATA1
#define OUT_CPU0 LATCbits.LATC0
#define OUT_CPU1 LATCbits.LATC1
#define OUT_CPU2 LATCbits.LATC2
#define OUT_CPU3 LATBbits.LATB3
#define OUT_CPU4 LATBbits.LATB4
#define OUT_CPU5 LATBbits.LATB5
#define OUT_CPU6 LATBbits.LATB6
#define OUT_CPU7 LATBbits.LATB7
#define IN_CPU0 PORTCbits.RC0
#define IN_CPU1 PORTCbits.RC1
#define IN_CPU2 PORTCbits.RC2
#define IN_CPU3 PORTBbits.RB3
#define IN_CPU4 PORTBbits.RB4
#define IN_CPU5 PORTBbits.RB5
#define IN_CPU6 PORTBbits.RB6
#define IN_CPU7 PORTBbits.RB7
#define IN_WR PORTAbits.RA3
#define IN_STATUS_CS2 PORTAbits.RA2
// WR | Result
// 0 | WR Data : Z80 -> PIC
// 1 | RD Data : PIC -> Z80
// Private function prototypes
void isr_int2(void);
void isr_lowpri(void);
void EnviaByte(void);
void RecebeByte(void);
// ADC
void LerADC(int vporta);
// USB
void ComunicarUSB(void);
// SERIAL
void ComunicarSerial(void);
//------------------------------------------------------------
// PROGRAMA PRINCIPAL
//------------------------------------------------------------
void main()
{
// CONFIGURAR PORTAS
OSCCON = 0xFF; // Seta Oscilador Interno para 8 MHz
ADCON1 = 0x0F; // 0x0D => RA0=AN0, RA1=AN1, TODAS AS DEMAIS ANx = DIGITAIS; 0x0F para testes
PORTA = 0x30;
PORTB = 0x00;
PORTC = 0x00;
TRISA = 0x0C; // 0x0F => RA7-X, RA6-X, RA5-INTZ80, RA4-CTRWAIT, RA3-WR, RA2-CS2, RA1-AN1, RA0-AN0; 0x0C para testes
TRISB = 0xFC; // RB7 A RB3 - D7 A D3, RB2-INT2/CS2, RB1-SCL, RB0-SCA
TRISC = 0x97; // RC7-RX, RC6-TX, RC5-D+, RC4-D-, RC3-X, RC2 A RC0 - D2 A D0
RCON = RCON | 0x80;
PIR1 = 0x00;
PIR2 = 0x00;
PIE1 = 0x00;
PIE2 = 0x00;
IPR1 = 0x00;
IPR2 = 0x00;
INTCON = 0xC0; // 0xC0
INTCON2 = 0xE0; // 0xE0
INTCON3 = 0x90; // 0x90
INTCON3bits.INT2IE = 0x00;
INTCON3bits.INT2IF = 0x00;
PIE1bits.RCIE = 0x00;
PIR1bits.RCIF = 0x00;
PIE2bits.USBIE = 0x00;
PIR2bits.USBIF = 0x00;
pbyte = 0x00;
pfunc = 0x00;
plerverif = 0x00;
pbytectrl = 0x00;
OUT_SDA = 0x00;
OUT_SDL = 0x00;
OUT_TSTR = 0x01;
OUT_TSTY = 0x00;
INTCON3bits.INT2IE = 0x01;
...
}
Last edited by a moderator: