leunglhz
Junior Member level 3
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
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