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.

UART Write problem. is it bug of Mikro C ? or what is the problem ?

Status
Not open for further replies.

ahmad2005

Member level 1
Joined
Mar 30, 2011
Messages
40
Helped
2
Reputation
4
Reaction score
2
Trophy points
1,288
Location
Mirpur,Dhaka,Bangladesh
Activity points
1,618
I uploaded my full work. any one can check.
see the picture
Here is the code//


Code C - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
char *uart_rd,output,aux;
char data1[12];
int data_size;
int i,x;
/*
// LCD module connections
sbit LCD_RS at RB4_bit;
sbit LCD_EN at RB5_bit;
sbit LCD_D4 at RA0_bit;
sbit LCD_D5 at RA1_bit;
sbit LCD_D6 at RA2_bit;
sbit LCD_D7 at RA3_bit;
 
sbit LCD_RS_Direction at TRISB4_bit;
sbit LCD_EN_Direction at TRISB5_bit;
sbit LCD_D4_Direction at TRISA0_bit;
sbit LCD_D5_Direction at TRISA1_bit;
sbit LCD_D6_Direction at TRISA2_bit;
sbit LCD_D7_Direction at TRISA3_bit;
*/
 /*
char txt3[] = "Lcd4bit";
char txt4[] = "example";
 */
void setup() {
  TRISB.RB3=0;
  TRISB.RB0=0;
  TRISB.RB6=0;
  PORTB.RB0=0;
  PORTB.RB3=0;
  PORTB.RB6=0;
 
  CMCON=7;
 
  UART1_Init(9600);               // Initialize UART module at 9600 bps
  /*
  Lcd_Init();                        // Initialize LCD
  */
  /*
  Lcd_Cmd(_LCD_CLEAR);               // Clear display
  Lcd_Cmd(_LCD_CURSOR_OFF);          // Cursor off
  Lcd_Out(1,6,txt3);                 // Write text in first row
 
  Lcd_Out(2,6,txt4);                 // Write text in second row
  Delay_ms(2000);
  Lcd_Cmd(_LCD_CLEAR);               // Clear display
  */
 
  Delay_ms(100);                  // Wait for UART module to stabilize
 /* for (i=0;i < 5;i++){
        delay_ms(100);
    }
       */
 
}
 
 
void main() {
 setup();
 
 UART1_Write_Text("AT+SAPBR=3,1,\"Contype\",\"GPRS\"");
  UART1_Write(0x0D);
  UART1_Write(0x0A);
  do{
        while(UART1_Data_Ready() == 0);
    }while(UART1_Read()!= 'K');
    delay_ms(200);
    PORTB.RB3=1;
 
  UART1_Write_Text("AT+SAPBR=3,1,\"APN\",\"wap\"");
  UART1_Write(0x0D);
  UART1_Write(0x0A);
  do{
        while(UART1_Data_Ready() == 0);
    }while(UART1_Read()!='K');
    delay_ms(100);
     PORTB.RB3=0;
 
   UART1_Write_Text("AT+SAPBR=1,1");
  UART1_Write(0x0D);
  UART1_Write(0x0A);
  do{
        while(UART1_Data_Ready() == 0);
    }while(UART1_Read()!='K');
    delay_ms(100);
    PORTB.RB3=1;
 
  UART1_Write_Text("AT+HTTPINIT");
  UART1_Write(0x0D);
  UART1_Write(0x0A);
  do{
        while(UART1_Data_Ready() == 0);
    }while(UART1_Read()!='K');
    delay_ms(100);
    PORTB.RB3=0;
 
 
  UART1_Write_Text("AT+HTTPPARA=\"CID\",1");
  UART1_Write(0x0D);
  UART1_Write(0x0A);
  do{
        while(UART1_Data_Ready() == 0);
    }while(UART1_Read()!='K');
    delay_ms(100);
    PORTB.RB3=1;
 
  UART1_Write_Text("AT+HTTPPARA=\"URL\",\"maruf.eee-lab.com/maruf.txt\"");
  UART1_Write(0x0D);
  UART1_Write(0x0A);
  do{
        while(UART1_Data_Ready() == 0);
    }while(UART1_Read()!='K');
    delay_ms(100);
    PORTB.RB3=1;
    PORTB.RB0=1;
    
UART1_Write_Text("AT+HTTPACTION=0");  //Connects with the HTTP server, this action can need to wait a several time
  UART1_Write(0x0D);
  UART1_Write(0x0A);
    x=0;
    do{
        while(UART1_Data_Ready()==0);
    }while(UART1_Read()!=0x2C);
    PORTB.RB3=0;
    PORTB.RB0=0;
    do{
        while(UART1_Data_Ready()==0);
    }while(UART1_Read()!=0x0A);
    delay_ms(100);
    PORTB.RB3=0;
    PORTB.RB0=0;
 
    UART1_Write_Text("AT+HTTPREAD=0,200");   //Reads 200 bytes from byte 0
    UART1_Write(0x0D);
    UART1_Write(0x0A);
 
    do{
        while(UART1_Data_Ready()==0);
    }while(UART1_Read()!=':');
 
   data_size=0;
    while(UART1_Data_Ready()==0);
 
    aux=UART1_Read();
    do{
        data_size*=10;
        data_size+=(aux-0x30);
        while(UART1_Data_Ready()==0);
        aux=UART1_Read();
    }while(aux!='\r');
 
    do{
        while(UART1_Data_Ready()==0);
    }while(UART1_Read()!='\n');
 
    for(x=0;x<=data_size;x++){
        while(UART1_Data_Ready()==0);
    data1[x]=UART1_Read();
    }
 
    if(data1[0]=='1')
    {
    PORTB.RB6=1;
    }
    else
      {
        PORTB.RB6=0;
      }
 
 delay_ms(5000);
 
}





**broken link removed**

<html><a title="problemNo1.png" href="http://obrazki.elektroda.pl/3879016700_1353768372.png"><img src="http://obrazki.elektroda.pl/3879016700_1353768372_thumb.jpg" alt="problemNo1.png" /></a></html>

**broken link removed**
 

Attachments

  • problemNo1.png
    problemNo1.png
    215.3 KB · Views: 106
  • P16F628.zip
    46.2 KB · Views: 89
Last edited by a moderator:

maybe you compiled some other copy of code with the string you are getting.
 

Yes, it is not working properly. maybe an error of mikroC or Proteus.
 

So. this error "IRP bit must be set manually for indirect access to '?lstr6" was causing the problem.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top