PDA

View Full Version : Read SIM 1st message and display it in a 20x4 LCD



loosha
- 8th December 2013, 04:47
Hello every one.

I am trying to read SIM 1st massage and display it in a 20x4 LCD
I am using PIC18F2550,20x4 LCD and wavecom-gsm-gprs-modem-q2303a.
When I send this command .The reply is as below…

AT+CMGR=1
AT+CMGR=1

.+CMGR: "REC READ","+8801678715550",,"13/12/05,18:54:31+24"
.Hello Love Loo.This is a test massage.

OK

But when I try to display it in a LCD .It display only….

+CMGR: “RE

7176

I want to display the whole massage
“Hello Love Loo.This is a test massage.”

Can anyone help me out…

My Code is....



'************************************************* ******************
#CONFIG
__CONFIG _CONFIG1L, _PLLDIV_5_1L & _CPUDIV_OSC1_PLL2_1L & _USBDIV_2_1L
__CONFIG _CONFIG1H, _FOSC_HSPLL_HS_1H & _FCMEN_OFF_1H & _IESO_OFF_1H
__CONFIG _CONFIG2L, _PWRT_OFF_2L & _BOR_ON_2L & _BORV_3_2L & _VREGEN_ON_2L
__CONFIG _CONFIG2H, _WDT_OFF_2H & _WDTPS_512_2H
__CONFIG _CONFIG3H, _CCP2MX_ON_3H & _PBADEN_OFF_3H & _LPT1OSC_OFF_3H & _MCLRE_ON_3H
__CONFIG _CONFIG4L, _STVREN_ON_4L & _LVP_OFF_4L & _XINST_OFF_4L

#ENDCONFIG
'************************************************* ***************
'Define OSC 48 ' Core is running at 48MHz
'******************** Definitions *******************************
'DEFINE OSC 4 'for 4 Mhz
DEFINE OSC 8 'for 8 Mhz

DEFINE HSER_TXSTA 20h 'I wonder shall I define as DEFINE HSER_TXSTA 24h???
DEFINE HSER_RCSTA 90h 'same for all

'DEFINE HSER_BAUD 2400 'for 2400 Baud rate
'DEFINE HSER_BAUD 4800 'for 4800 Baud rate
DEFINE HSER_BAUD 9600 'for 9600 Baud rate

'DEFINE HSER_SPBRG 25 'for 4Mhz/2400 & 8Mhz/4800 with an error %0.16
DEFINE HSER_SPBRG 12 'for 4Mhz/4800 & 8Mhz/9600 with an error %0.16

DEFINE HSER_CLROERR 1 'same for all

DEFINE NO_CLRWDT '// Saves 17 words code space


'**************** Allocate variables ***************************
'**************** define variables ***************************

Sedata var byte[40]
TELNO var byte[11] ' array for phone number
i var byte ' Define loop variable
Sta var bit
Line var byte 'LCD line address
K VAR BYTE 'counter
KC VAR BYTE 'counter

'******************* Initialization ****************************
TRISA=%00000111 ' Set PORTD to all output
TRISB=%00000000 ' Set PORTD to all output
TRISC=%10000001 ' Set PORTD to all output

' ansel=%00000011
CMCON = 7


PORTB=%00000000
PORTA=%00000000
Sta=0
ADCON1 = 15 ' Set PORTA and PORTE to digital

Line = $80 'LCD 1st line
K = 0
KC = 0
'----------------- Define LCD pins ------------------------------
define LCD_DREG PORTB ' LCD Data port
define LCD_DBIT 0 ' starting Data bit (0 or 4) if 4-bit bus
define LCD_RSREG PORTB ' LCD Register Select port
define LCD_RSBIT 5 ' LCD Register Select bit
define LCD_EREG PORTB ' LCD Enable port
define LCD_EBIT 4 ' LCD Enable bit
define LCD_LINES 4 ' Number of lines on LCD

'------------------------ End of Declare LCD -----------------------------
lcdout $FE,$80,"GSM SMS Center V1.0 " ' Display Key board V1.0
Pause 1000 ' Delay 1 Sec
lcdout $fe,$1 ' Clear Screen
'--------------------------- mainloop -----------------------------------
GSM_CHECK:
HSEROUT ["AT",13] 'Send AT to modem followed by a CR
HSERIN 5000, GSM_CHECK, [WAIT("OK")] 'Check OK reply, wait 5sec max.
lcdout $FE,$80," Step 1 " ' Display Key board V1.0
PAUSE 1000

HSEROUT ["AT+IPR=9600",13] 'Set transfer speed
HSERIN 5000, GSM_CHECK, [WAIT("OK")]'Check OK reply, wait 5sec max.
lcdout $FE,$80," Step 2 " ' Display Key board V1.0
PAUSE 1000

HSEROUT ["AT+CMGF=1",13] 'send AT to modem followed by a CR and line feed
HSERIN 5000, GSM_CHECK, [WAIT("OK")]'Check OK reply, wait 5sec max.
lcdout $FE,$80," Step 3 " ' Display Key board V1.0
PAUSE 1000

BEGIN:
if PORTC.0 = 0 & Sta=0 then
goto SEND_SMS
else
goto READ_SMS
endif
PAUSE 1000

GOTO BEGIN


READ_SMS:
HSEROUT ["AT+CMGR=1",13] 'send AT to modem followed by a CR and line feed
HSERIN 5000,READ_SMS,[WAIT("AT+CMGR=1"),STR Sedata\13]'Check OK reply, wait 5sec max.
' Sedata = Sedata << 3
' SKIP 10,
loo:
lcdout $fe,Line+KC,Sedata[K]
PAUSE 1000

K = K+1
KC = KC+1

if K < 19 then goto loo

KC = 0
Line = $C0
if K < 39 then goto loo

Looop:
PAUSE 1000
GOTO Looop

SEND_SMS:

lcdout $FE,$80," SMS Send > > " ' Display Key board V1.0
GOTO BEGIN


ERROR_SMS:
LCDOut $fe,1,"NO RESPONS!",$fe,$c0,"CHECK SIM/PHONE"
Pause 3000
GOTO BEGIN

end

Dave
- 8th December 2013, 21:18
Loosha, The lines for the lcd are started form $80 for first line, $C0 for second line, $94 for third line and, $D4 for forth line. I do not see where you are sending any daya to any line other than the first line.

loosha
- 9th December 2013, 06:22
Just I think so you don’t see the code carefully.
In my initialization I do the work.
Line = $80 'LCD 1st line

EarlyBird2
- 8th June 2014, 23:30
This instruction

HSERIN 5000,READ_SMS,[WAIT("AT+CMGR=1"),STR Sedata\13]'Check OK reply, wait 5sec max.

reads in 13 characters

this is what you should have

HSERIN 5000,READ_SMS,[WAIT("AT+CMGR=1"),STR Sedata\40\13]'Check OK reply, wait 5sec max.

Which will read in 40 characters but stop if a ASCII 13 is read.