Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Problem with sending AT commands through 8051 (T68i and AT89S52)

Status
Not open for further replies.

leunglhz

Junior Member level 3
Joined
Jan 29, 2008
Messages
26
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,507
schematic t68i

I am doing a project on SMS controller with SonyEricsson T68i and AT89S52.

I can send message using AT command via Hyperterminal, but I hv problem with sending it through 8051.

I connected the T68i port directly to the microcontroller, becoz I couldn't find the RS232 Cable. (RXD, TXD and GND of T68i connected to the TXD, RXD and GND of the AT89S52)

Below is my code

Do I need to initialize the phone? Or is it connection oproblem?

Can anyone tell me my problem? Thx!




ORG 0000H ; begins at ROM location 0000H
LJMP MAIN ; bypass interrupt Vector Table

;-----------------ISR(Interupt Service Routine)-------------------------------

ORG 0013H ;INT1 in IVT
SETB P1.2 ;turn on LED
SETB P1.4 ;turn on Buzzer
ACALL SENDMSG ;send MSG
ACALL LONGDELAY ;delay for 10s
CLR P1.2 ;turn off LED
CLR P1.4 ;turn of Buzzer
RETI ;return from interrupt

;------------------------Main Program---------------------------------------

ORG 30H ;
MAIN: CLR P1.2 ;turn off LED
CLR P1.4 ;turn off Buzzer
SETB TCON.2 ; make INT1 edge-trigger interrupt
MOV IE, #10000100B ; enable external INT1
SETB P2.0
HERE:
SJMP HERE ; Stay here until get interrupted

;-----------------------Send MSG--------------------------------------------

SENDMSG:
CALL SET_UART
MOV DPTR, #PDU_LENGTH
CALL TRANCHAR
CALL RECEIVE_prompt
MOV DPTR, #PDU_CONTENT
CALL TRANCHAR
ret

PRINTCHAR:
JNB TI, $ ;Return to itself if TI is not set.
CLR TI ;Clear TI
MOV SBUF, A
RET

TRANCHAR:
CLR A
MOVC A, @A+DPTR ;point single byte of data to A
INC DPTR
JNZ printChar ;Jump if A not 0 TO check if all byte transmited
RET


SET_UART:

MOV TMOD, #20H ; timer 1, mode 2 (auto reload)
MOV SCON, #50H ; 8 bit data, 1 stop bit, 1 start bit, and REN
MOV TH1, #0FDH ; timer 1 high byte, -3register value for 9600 baud rate
SETB TR1 ; Start timer 1
RET

RECEIVE_prompt:

JNB RI, HERE ;Wait for 1st bytes char prompt "> " to come out
CLR RI ;Clear receive interrupt
JNB RI, HERE ;Wait for 1st bytes char prompt "> " to come out
CLR RI ;Clear receive interrupt
CALL SHORTDELAY ;wait for a moment
RET

;---------------------------Delay----------------------------------------------

LONGDELAY:
MOV R2, #50 ;~1S
S1: MOV R3, #200
S2: MOV R4, #200
DJNZ R4, $
DJNZ R3, S2
DJNZ R2, S1
RET


SHORTDELAY:

MOV R2, #50 ;~0.5S
S11: MOV R3, #250
S22: MOV R4, #250
DJNZ R4, $
DJNZ R3, S22
DJNZ R2, S11
RET



;------------------------On Chip Code Spce for Storing Data----------------------------------
ORG 250

PDU_LENGTH:
DB "AT+CMSG=37",0DH, 00H ;"send Message" AT command and TPDU length

PDU_CONTENT:
DB "07915892945897F501000B915862806461F400001BD9775D0E1296D96FF739ED3ECF4141791914A683A4E9F91A", 1AH, 00H ;PDU Content (SMSC and TPDU) 1AH = <Ctrl+z>



END
 

at89s52 rxd and txd program

Brother u need to connect MAX 232 IC i-e logic converter. 89c52 uses logic
0-----0V
1-----5V

While pC serial port uses logic

0----+3->+12V
1----- -3->-12V
 

    leunglhz

    Points: 2
    Helpful Answer Positive Rating
t68i rs232

Hi,
If you did not have RS232 cable, how did you connect it to PC? And do you have some other pins from the phone which you connected to the controller? If you are connecting the same points which you connected to PC, then you will need RS232 drivers as explained above.
Regards,
Laktronics
 

    leunglhz

    Points: 2
    Helpful Answer Positive Rating
t68i pdu to text

Thx for replying

For connection with PC, I used USB cable

But as far as I know, 8051 does not support USB.

For connection with microcontroller, I cut off the end of the USB cable and connect directly to it (with resistors to provides 3V to microcontroller), becoz mobile and microcontroller both use TTL logic.

Is there other ways to link USB cable to 8051?
 

at89s52 commands

Hi,
You can not connect like that. 8051 can not easily play the role of USB host as done by PC interface. If you want to connect to micro controller, you have to get a serial cable for phone and connect it to microcontroller using a MAX232 like TTL to RS232 converter.
Regards,
Laktronics
 

    leunglhz

    Points: 2
    Helpful Answer Positive Rating
sending at-command to t68i

It still don't get why its not possible to connect the phone directly to the 8051?

MAX232 convertor is needed only if serial cable is used, becoz this cable convert TTL to RS232.

In my case, I have cut off the end of the USB Cable, and the cable is just acting like a connector with nothing more than wire.

Microcontroller - 0-5V

Mobile - 0-3V

Both TTL, should work properly.

Is it possible that some initialization is required to set up the connection?
 

t68i pin cable

Hi,
You have mentioned that while connecting to PC, you have connected the phone to the USB port of PC, which means the phone is interfacing to PC using USB signals, it does not matter whether the level is TTL or not, you need to emulate a USB host in 8051 for it to work with your phone. Apart from just the levels, it means a lot of software to manage the USB communication will be required on 8051 side. Just by cutting of the connector, the interface does not become compatible.
Regards,
Laktronics
 

    leunglhz

    Points: 2
    Helpful Answer Positive Rating
t68i 232 cable sale

Hi,

I've brought the serial cable from the internet!

However, the phone still not responding.

The voltage across the TxD and RxD are high initially. Is it usual?

thx
 

t68i one-wire

Hi,
Does the phone work with PC when connected using the serial cable?

Most of these cables contain RS232 IC's and its power supply circuits on the cable itself. These circuits draw power from DTR/ RTS signals of the RS232 port. Also for a direct connection to PC's port if the phone is working, it means the TX/RX pins are reversed in cabe to make it compatible with PC's connector. So, you have to bringout your controller signals including DTR/RTS on a connector with pins matching with PC's connector. You have to make sure that DTR/RTS output will be around +12V during communication so that your cable gets necessary power for its citcuit to work. If, on connecting to the cable, these signals fall in level, you can disconnect MAX 232 output from these pins and simply connect a +12 V supply with a series resistor of about 300 ohms to DTR/RTS pins.
By the way,do you have internal circuit diagram for your cable? TX output will be
-12V nominal when RS232 is in idle state. RX being input it may depend on the design of the circuit.

Regards,
Laktronics
 

    leunglhz

    Points: 2
    Helpful Answer Positive Rating
t68i serial port connector

The cable works with Hyperterminal without any software installation.

I have made a null modem connection, with the RXD and TXD of the 8051 to the TXD and RXD of the cable respectively. When Idle, The TXD and RXD of the cable is around -10V, and 0V.


Could you explain more about this:

laktronics said:
So, you have to bringout your controller signals including DTR/RTS on a connector with pins matching with PC's connector. You have to make sure that DTR/RTS output will be around +12V during communication so that your cable gets necessary power for its citcuit to work.
Laktronics

How should I connect the DTR/RTS pins in order to provide power to the cable?

I've attached the circuit diagram of my controller, and the t68i schematic can be found in the following post



Thx
 

at89s52 with at command

Hi,
Your connection is fine, NO need for any DTR/RTS connection. Make sure that the ground connection of 8051 is extended to the phone through the cable and apply 5V and ground to the USB connector of the cable.
Now if you send AT commands as you have sent from PC, similar response should come from the phone to the microcontroller.
Regards,
Laktronics
 

    leunglhz

    Points: 2
    Helpful Answer Positive Rating
T68i and AT89S52

The mobile is still not responding. Do you think it is the program problem?

When I check the voltage output across the TXD of 8051, the voltage is high. How can i check whether the 8051 is sending data to the TXD pin?

Thanks
 

Re: T68i and AT89S52

Hi,
1. I hope you have programmed 8051 for required baud rate and NO Parity, 8 bit data and 1 Stop bit mode.
2.You can connect 8051 to PC using a crossed TX/RX null modem cable and check the correctness of its working.
3. When sending data you can also observe pulses at TX with an oscilloscope. In any case checking with PC first is the best method.
Regards,
Laktronics
 

    leunglhz

    Points: 2
    Helpful Answer Positive Rating
Re: T68i and AT89S52

Hi leunglhz,

I could not find that you send the <CR><LF> in your program. I think you need to send <CR><LF> at the and of sending PDU command.
 

    leunglhz

    Points: 2
    Helpful Answer Positive Rating
T68i and AT89S52

Thx for your suggestion,

I have connected the 8051 to the computer and send the command to the Hyperterminal. There are some mistakes in my code, and I made some modification and now the correct AT commands appear on the screen.

However, there is still no respond when I connected the 8051 to the phone. I hv triedmany different connections, like shorting the DTR and DSR, RTS and CTS....

Do you have any idea?
 

Re: T68i and AT89S52

Hi,

1. While testing with 8051 circuit with PC, you have to make sure that the setting of the hyper terminal should be same as the settings used when communicating between PC and phone.

2. As the previous post says you have to add <CR> after each AT command line from 8051?

3. Make the situation the same when testing under (PC+phone) and (8051+phone)

4. I suppose you ensure that character codes sent out are same in both the cases.

5. Is your 8051 serial receive routine OK?, that is, how do you say the phone is not responding? If you are going by the response of 8051, may be you can check it also by sending such response bytes from PC to 8051?

6. If you are sure that the schematic you have quoted above for your cable is correct, then no need to worry about control signals DTR/RTS since those wires are not connected on the PC end of your cable. Please visually check it again on the 9pin connector end of your phone cable that only 3 wires are connected to it. I am fully going by the information given by you that the phone cable diagram is the one you have referred. You can also verify this by connecting only TX/RX and ground signals from your phone cable connector through a small adaptor cable to PC and verifying if it works OK.

Regards,
Laktronics
 

    leunglhz

    Points: 2
    Helpful Answer Positive Rating
Re: T68i and AT89S52

I used the same UART settings for both connections (8051 and computer, mobile and computer), which are 8 bit data, 9600 baud rate, No parity, 1 stop and start bit. Therefore, when 8051 is connected to the mobile, the UART settings should be the same.

I am using PDU mode instead of text mode.

When tested with hyperterminal, the phone sent a message to my mobile phone, and thats the respond I am refering to. I think serial receive rountine is not needed, as I am only sending command to the phone.

I think the problem most likely is the connection between the phone cable and the 8051. I will check the mobile phone cable and tell you the result.

Thanks
 

Re: T68i and AT89S52

Hi,
Except for PDU mode, other things what you have done is OK, I do not have the details of PDU mode, I hope you would have taken care that all codes sent out from 8051 are same as those from PC. Then only thing left out is cable checking with an adaptor null modem cable, make it of short length to ensure that it does not affect the performance.

Regards,
Laktronics
 

    leunglhz

    Points: 2
    Helpful Answer Positive Rating
Re: T68i and AT89S52

I hv tested the cable connection wtih the PC. I remove each pin one by one and test the connection, and the result is as follows:

Pin 2,3,5,7,8 are required for successful connection

Pin 7 and 8 are the "Request to Send" and the "Clear to Send" pins.

Refering to the cable schematic of T68i, pin 7 and 8 are actually connected to the max3232.

Do you know why these pins are connected, and how should I connected these pin s to the 8051??

Thanks
 

Re: T68i and AT89S52

Hi,
Need for 7 and 8 may be due to one of these:
1. Hyper terminal requires a short of RTS/CTS which I expect will only be required if you have enabled hardware handshake in hyperterminal. This you can verify if you disconnect wires coming from phone to pins 7 and 8 of the PC side connector of the adaptor cable and make a local short of 7 and 8 on the PC connector instead and see if it works.

2. Unused gates of Max 232 may require a connection or internally the circuit may be using RTS signal. To test this, disconnect wire from pin 8 and keep pin 7 connected. This will provide receive gate of MAX232 required signal but you do not short 7 and 8 on PC connector side. If it works you can connect pin 7 to a zener regulated +12V supply on your 8051 board through a 470 ohm resistor, it may even work with a 5V supply instead of 12V.

If the 7 and 8 connection is required because of case1, it is not required in 8051 since your program does not need any handshake signal.

Regards,
Laktronics
 

    leunglhz

    Points: 2
    Helpful Answer Positive Rating
Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top