Hi Guys,
I have a problema very intersting. I use the 18F2550, and i am trying read from PIN RB2 anything, but this pin dont response. In my last try, i am using RB2 as INT2, active in the faling of signal, but i can put 0v, 5v, 2v, 10v, 50v, -150v, and nothing, the pin dont accept the interruption. And the same with reading, the RB2 dont return anithing. It seems he's always in "1", or in three-state.
I am set all registers of interruptions, in ADCON1, I had put only RA0 and RA1 as analogic (for A/D), all other pin as digital input/output, i disable all interruptions from peripherics, i put INT2 as High Priority, ans other as Low, and nothing.
Below, my code, make in c++.
Some1 have any idea, PLZ.
Ty a lot
Moacir Jr.
I have a problema very intersting. I use the 18F2550, and i am trying read from PIN RB2 anything, but this pin dont response. In my last try, i am using RB2 as INT2, active in the faling of signal, but i can put 0v, 5v, 2v, 10v, 50v, -150v, and nothing, the pin dont accept the interruption. And the same with reading, the RB2 dont return anithing. It seems he's always in "1", or in three-state.
I am set all registers of interruptions, in ADCON1, I had put only RA0 and RA1 as analogic (for A/D), all other pin as digital input/output, i disable all interruptions from peripherics, i put INT2 as High Priority, ans other as Low, and nothing.
Below, my code, make in c++.
Rich (BB code):
void main()
{
unsigned int cc;
// CONFIGURAR PORTAS
ADCON1 = 0x0D; // RA0=AN0, RA1=AN1, TODAS AS DEMAIS ANx = DIGITAIS
PORTA = 0x30;
PORTB = 0x00;
PORTC = 0x00;
TRISA = 0x0B; // RA7-X, RA6-X, RA5-INTZ80, RA4-CTRWAIT, RA3-PC6, RA2-X+/Y+, RA1-AN1, RA0-AN0
TRISB = 0xFC; // RB7 A RB3 - D7 A D3, RB2-INT2/CS2, RB1-SCL, RB0-SCA
TRISC = 0x97; // RC7-RX, RC6-TX, RC5-D+, DC4-D-, RC3-X, RC2 A RC0 - D2 A D0, RE3-PC5
RCON = RCON | 0x80;
PIR1 = 0x00;
PIR2 = 0x00;
PIE1 = 0x40;
PIE2 = 0x20;
IPR1 = 0x00;
IPR2 = 0x00;
INTCON = 0x80; // 0x80
INTCON2 = 0xE0; // 0xE0
INTCON3 = 0x90; // 0x90
pbyte = 0xD5;
OUT_TFFT = 1;
cc = 0;
while(1)
{
if (cc <= 0x06FF)
OUT_TFFT = 1;
else
OUT_TFFT = 0;
cc++;
if (cc > 0x0EFF)
cc = 0;
}
}
void isr_reset(void) __interrupt 0
{
main();
}
void isr_int2(void) __interrupt 1
{
unsigned char vINT;
vINT = INTCON3 & 0x02;
if (vINT == 0x02) // FLAG DE INT2 DISPARADA
{
// DESLIGA FLAG DE INT2
INTCON3 = 0x90;
#ifndef debug
if (IN_PC6 == 0 && IN_PC5 == 1) // WR DADOS
pbyte = RecebeByte();
else if (IN_PC6 == 1 && IN_PC5 == 0) // RD DADOS
EnviaByte(pbyte);
else if (IN_PC6 == 1 && IN_PC5 == 1) // RD CTRL
EnviaByte(pbyte);
#endif
}
}
Ty a lot
Moacir Jr.
Last edited by a moderator: