Here is the code, if u could check it, knowing ATmega 8515 and the simulation shows that everything is ok and each character is sent
.include "m8515def.inc"
.def Arg1 =r16
.def Arg2 =r17
.def DataReg =r18 ;UART and EEPROM data register
.def any_reg2 =r19
.def temp =r20
.def temp1 =r21
.def temp2 =r22
.def over =r23
.def over1 =r24
.def any_reg =r25
.def bit_mask1 =r26
.def bit_mask2 =r27
.def count =r28
.equ brp = 25 ; Baud rate parameter
.equ CR =0x0D
.equ LF =0x0A
.org 0x00
rjmp reset
.org UDREaddr
rjmp udr_empty_int
reset:
cli
ldi temp, high(RAMEND) ;stack initialization
out SPH, temp
ldi temp, low(RAMEND)
out SPL, temp
clr count
clr ZL
clr r0
clr any_reg
clr over
clr temp
clr temp1
clr temp2
clr Arg1
clr Arg2
clr DataReg
ldi bit_mask2,0b00000001
ldi bit_mask1,0b11111110
ldi over, 0x00 ;store 0 in R17
out DDRA, over ;Store this value in The PORTA Data direction Register
ldi over1,0xff
out DDRB, over1
;Command strings MUST be located within the first 256 bytes of flash to use only low 8bit address
cmd_at: .db 'A','T',0
cmd_init: .db 'A','T','+','C','P','M','S','=','"','S','M','"',',','"','S','M','"',0
cmd_msgsend: .db 'A','T','+','C','M','S','S','=','1',0
;------------------------------------------------------
;UART initialization:
;----------------------------------------------------
sbi UCSRB,3 ; TX enable
cbi UCSRA,1 ; U2X enabled
ldi temp1, high(brp) ; Baud Rate = 19200 bps
out UBRRH, temp1
ldi temp1, low(brp)
out UBRRL, temp1
ldi temp2,0b11000110 ; (synchronous,no parity, 1 stop bit, 8 data bit )
out UCSRC,temp2
cbi UCSRB,UDRIE
sei
;------------------------------------------------------------------
;start sending SMS when sensor activated
;------------------------------------------------------------------
main:
in temp1,PINA
sbrc temp1,0 ;Skip if Bit0 in PORTA is clear
rjmp main
rcall start
rjmp main
;-------------------------------------------------------------------
;Sending The 3 AT commands
; 1- AT
; 2- AT+CPMS="SM","SM"
; 3- AT+CMSS=?
;-------------------------------------------------------------
start:
SEND_AT:
ldi zh,high(cmd_at*2)
ldi zl,low(cmd_at*2)
rcall send_cmd
SMS_INIT:
ldi zh,high(cmd_init*2)
ldi zl,low(cmd_init*2)
rcall send_cmd
sbi portb,4 ; Check LED
SMS_SEND:
ldi zh,high(cmd_msgsend*2)
ldi zl,low(cmd_msgsend*2)
rcall send_cmd
sbi portb,3 ; Check LED
;-------------------------------------------------------------------------
; Send AT Command (Char ,<CR>,<LF>)
;-------------------------------------------------------------------------
send_cmd:
scmd_loop:
lpm
tst r0 ;test ro
breq scmd_cr ;branch if ro=zero
mov DataReg,r0
sbi UCSRB,UDRIE
rcall wait_one_byte_tx
inc zl
rjmp scmd_loop
scmd_cr:
ldi DataReg, CR ;send command terminator <CR>
sbi UCSRB,UDRIE
rcall wait_one_byte_tx
ldi DataReg, LF ;send Line Feed <LF>
sbi UCSRB,UDRIE
rcall wait_one_byte_tx
sbi portb,1 ; check LED
ret
;--------------------------------------------------------------
; Wait For One Byte
;--------------------------------------------------------------
wait_one_byte_tx:
sbrs any_reg,0 ; this bit will be set in the UDR empty int
rjmp wait_one_byte_tx:
and any_reg,bit_mask1 ; bit_mask1= 11111110
ret
;---------------------------------------------------------------
;UDREaddr Interrupt Handler
;------------------------------------------------------------
udr_empty_int:
out udr,DataReg
or any_reg,bit_mask2 ; bit_mask2 = 00000001
cbi UCSRB,UDRIE
exit:
reti
Plz check the underlined part concerning the Baud Rate which is for 19200 bps,8MHz Clock, Synchronous the UBRR = 25 which is saved only in UBRRL and the UBRRH =0 but UCSRC always changes the UBRRH as they share the same location.
Thanx for ur efforts