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.

[SOLVED] Problem with MikroC Pro when reading SMS using UART1_Read_Text

Status
Not open for further replies.

KasunLK

Newbie level 2
Joined
Jul 19, 2011
Messages
2
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,311
Hi

I am new to MikroC and I have a problem with UART1_Read_Text();
I use Real PIC Simulator 1.1, My Mobile connected to COM7

Please help me.

I can send SMS, No problem, it works fine.

but when i receive SMS,

(1) i can read it char by char using UART1_Read();
output[0] = UART1_Read();

(2) if I use variable 'i' for array index, then I get garbage values.
output = UART1_Read();


(3) if I use following(Pls See below ) code, it gives garbage again.
UART1_Read_Text(output, 0X0D+0X0A , 90);


In fact it is like this. It reads numbers well.
but when reading characters it missing first bits.

eg:- for "REC" which is "1010010(R) 1000101(E) 1000011(C)"
it gives "<DC2><ENQ><ETX>" which is "0010010(<DC2>) 0000101(<ENQ>) 0000011(<ETX>)"

ASCII-characters
ASCII character set

How do I solve this problem.


My code like this

uart1_init(9600);
delay_ms(100);

uart1_write_text("AT+CMGR=1");
delay_ms(1);

UART1_Write(0X0D);
Delay_ms(1);

UART1_Write(0X0A);
strcpy(output,"");
Delay_ms(10);


b:
if (UART1_Data_Ready())
{
UART1_Read_Text(output, 0X0D+0X0A , 90);

UART1_Write_Text(output);
}

goto b;



Serial port Monitor giving like this (out put for above code)


COM port is opened
<20110719083248.658 SYS> //date(20110719) & time(083248) with event (SYS, TX,RX)
In/out queue size 1024/1024
<20110719083248.658 SYS>
Baud rate 9600
<20110719083248.658 SYS>
RTS off
<20110719083248.659 SYS>
DTR off
<20110719083248.659 SYS>
Data bits=8, Stop bits=1, Parity=None
<20110719083248.659 SYS>
Set chars: Eof=0xB0, Error=0x00, Break=0x00, Event=0x00, Xon=0x11, Xoff=0x13
<20110719083248.659 SYS>
Handflow: ControlHandShake=(), FlowReplace=(), XonLimit=256, XoffLimit=256
<20110719083248.659 SYS>
Set timeouts: ReadInterval=-1, ReadTotalTimeoutMultiplier=0, ReadTotalTimeoutConstant=0, WriteTotalTimeoutMultiplier=100, WriteTotalTimeoutConstant=1000
<20110719083248.770 TX>
AT+CMGR=1 [len=9]
<20110719083248.770 TX>
<LF>
<20110719083248.771 RX>
AT+CMGR=1 [len=10]
<20110719083248.773 RX>
<LF>
<20110719083248.820 TX>
<SOH><DC4>+<ETX> [len=5]
<20110719083248.820 TX>
<BEL><DC2>=1 [len=4]
<20110719083248.820 TX>
<LF>
<20110719083249.072 RX>
[len=1]
<20110719083249.072 RX>
<LF>+CMGR: "REC READ","32665",,"2009/12/08 18:20:01+22" [len=52]
<20110719083249.072 RX>
<LF>Facebook Mobile confirmation code: aaa222 [len=42]
<20110719083249.072 RX>
<LF> [len=1]
<20110719083249.072 RX>
<LF>OK [len=3]
<20110719083249.072 RX>
<LF>
<20110719083249.124 TX>
[len=1]
<20110719083249.124 TX>
<LF>+<ETX> [len=3]
<20110719083249.124 TX>
<BEL><DC2>: "<DC2><ENQ><ETX> <DC2><ENQ><SOH><EOT>","32665",,"2
<20110719083249.130 RX>
[len=1]
<20110719083249.130 RX>
<LF>+<ETX> [len=3]
<20110719083249.130 RX>
<BEL><DC2>: "<DC2><ENQ><ETX> <DC2><ENQ><SOH><EOT>","32665",,"2
<20110719083249.428 TX>
009/12/08 18:20:01+22" [len=48]
<20110719083249.428 TX>
<LF><ACK>!#%"//+ [len=10]
 

I think I found the reason.
it is array size.
it allows to create a char array of size 95
but it caused the problem with uart1_read_text()
I reduce the size to 80. then it work fine.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top