|
|
View previous topic :: View next topic |
Author |
Message |
T610 Guest
|
PIC to Modem problem |
Posted: Thu Jan 26, 2006 9:30 pm |
|
|
Hello to all.
I have one 16F628 connected to a T610 across a MAX232 because I use the datacable of the phone (DTR to 8 Volts approximately to activate the interna level shifter of the cable).
I have proved the code connecting the PC to stream=PC and the phone to stream=modem .... I have communication, in fact from the PC I send information to the PIC and this one transfers them to the phone. With this I made telephone calls..
But I have a problem...
Writing:
=======
61 74 0D at.
Reading:
=======
61 61 74 74 0D 0D aatt..
Awaited reading:
=============
61 74 0D 0D 0th 4F 4B 0D 0A CR CR LF O K CR LF
Finally, the sent characters are echoed from the phone, but repeated ..... and the response to the commands they are not received..
Can anybody face me?
Thank you
Code: | ////////////////////////////////////////////////////////////////////////////////
// //
// 16F628 Input Buffer //
#include <16F628.h>
//#fuses INTRC_IO
#fuses XT
#fuses NOWDT
#fuses PUT
#fuses BROWNOUT
#fuses NOPROTECT
#fuses NOMCLR
#fuses NOLVP
#fuses NOCPD
#use delay(clock=4000000)
#use rs232(baud=9600,parity=N,xmit=PIN_B2,rcv=PIN_B1,bits=8,stream=modem,errors)
#use rs232(baud=9600,parity=N,xmit=PIN_B5,rcv=PIN_B0,bits=8,stream=PC,errors)
#define BUFFER_SIZE 30
BYTE buffer[BUFFER_SIZE];
BYTE next_in = 0;
BYTE next_out = 0;
#define BUFFER_SIZE2 30
BYTE buffer2[BUFFER_SIZE2];
BYTE next_in2 = 0;
BYTE next_out2 = 0;
#int_rda
rda_isr() {
//output_high(PIN_B3);
int t;
buffer[next_in]=fgetc(modem);
t=next_in;
next_in=(next_in+1) % BUFFER_SIZE;
if(next_in==next_out)
next_in=t;
}
#int_EXT
ext_isr() {
int t2;
buffer2[next_in2]=fgetc(PC);
t2=next_in2;
next_in2=(next_in2+1) % BUFFER_SIZE2;
if(next_in2==next_out2)
next_in2=t2; //Buffer full
}
#define b_kbhit (next_in!=next_out)
#define b_kbhit_2 (next_in2!=next_out2)
char b_getc() {
char c;
while(!b_kbhit);
//while(next_in!=next_out);
c=buffer[next_out];
next_out=(next_out+1) % BUFFER_SIZE;
return (c);
}
char b_getc_2() {
char c2;
while(!b_kbhit_2);
//while(next_in2!=next_out2) ;
c2=buffer2[next_out2];
next_out2=(next_out2+1) % BUFFER_SIZE2;
return (c2);
}
void main() {
ext_int_edge(H_TO_L);
enable_interrupts(INT_EXT);
enable_interrupts(int_rda);
enable_interrupts(GLOBAL);
while(1) { // LOOP
while(1) {
if(b_kbhit) {
fputc(b_getc(),PC);
}
if(b_kbhit_2) {
fputc(b_getc_2(),modem);
}
}
}
}
|
|
|
|
T610 Guest
|
|
Posted: Thu Jan 26, 2006 11:23 pm |
|
|
When i send from PC:
After that, I receive a correct echo. This means that the previous command was got for the modem and executed satisfactorily, so that now he does not answer with an echo of the sent characters. Then it means that the code itself does an echo. But then, if the modem answers to the command, for what reason I do not receive any assertion, like an OK?
what is happening? |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|