KasunLK
Newbie level 2
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 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]