lloydi12345
Member level 4
Hi, We have a project and it is a sms based microcontroller. I'm using Sony Ericsson T68i for the phone and I'm using PDU format. Testing everything on hyperterminal seems alright. Now, going to simulation, programming on mikroC PRO and using a virtual serial port I was able to receive a response from the phone using only the usb data cable. I send "AT" to the phone using the uC and I was able to receive "AT and "OK" from it. The program runs fine but it does not really run on the way it should be. The problem is, the microcontroller doesn't seem to read the "OK" data which is parsed at the bottom of the program. If it is properly read, the 8th pin of portb should light the LED. Can you help me clear the problem?
This code below is working only until the 2nd character which is "T"
when I change the condition statement to this
It won't work. I don't know if it's right. I attached an image how the reply looks. This is the only idea I know how to check the "OK" data sent by the phone. If you have any other alternatives I would really be so thankful.
This code below is working only until the 2nd character which is "T"
Code:
unsigned char recv[9];
int x;
void main() {
portb = 0x00;
adcon1 = 0x06;
cmcon = 0x07;
trisb = 0x00;
uart1_init(9600);
delay_ms(1000);
uart1_write_text("AT");
uart1_write(10); //line feed
uart1_write(13); //carriage return
delay_ms(500);
for (x=0; x<9; x++){
while (uart1_data_ready()== 0){;}
recv[x] = uart1_read();
//check if response received
if (recv[0] == 'A' && recv[1] == 'T'){
portb.f7 = 1; //ouput led on
}
else {
delay_ms(100);
}
}
}
when I change the condition statement to this
Code:
if (recv[0] == 'A' && recv[1] == 'T' && recv[2] == '\n' && recv[3] == '\r' && recv[4] == 'O' && recv[5] == 'K' && recv[6] == '\n' && recv[7] == '\r')
It won't work. I don't know if it's right. I attached an image how the reply looks. This is the only idea I know how to check the "OK" data sent by the phone. If you have any other alternatives I would really be so thankful.