EngineersGarage

  • Engineers Garage Main Site
  • Visit our active EE Forums
    • EDABoard.com
    • Electro-Tech-Online
  • Projects & Tutorials
    • Circuits
    • Electronic Projects
    • Tutorials
    • Components
  • Digi-Key Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • Advertise
You are here: Home / Replies / The c program i used is given

The c program i used is given

|

Microcontroller › 8051 › Requires complete code for wireless notice board › The c program i used is given

April 20, 2013 at 4:26 am #9533
RUBEN KURIAKOSE
Participant

The c program i used is given below. But while compiling it there shows an error ‘DATA SEGMENT EXEEDS’. When i decrease the size of array a[161] it shows no error. But the loop works on 161.

 

#include <REGX51.H>
sbit rs=P1^0;
sbit rw=P1^1;
sbit en=P1^2;
void lcd_command(unsigned char);
void lcd_data(unsigned char);
void string(unsigned char *disp);
void delay(unsigned int);
void read(char*);
void newline();
void display (char);
void send();
void serial();
void nextline(unsigned char);
void nextline1(unsigned char);
void nextline2(unsigned char);
sfr chdata=0xA0;
void lcdnewline();
char a[161];
char b[13];
int i,j,z,k,l,f=0;
void main()
{
P0=0x00;
P1=0x00;
P2=0xFF;           
delay(100);               
lcd_command(0x38);
delay(100);
lcd_command(0x80);
delay(100);
lcd_command(0xc0);
delay(100);
lcd_command(0x0e);
delay(100);
lcdnewline();
serial();
read(“AT”);
newline();
read(“AT+CMGF=1”);
newline();
lcdnewline();
read(“AT+CMGD=1”);
newline();
lcdnewline();
while(1)
{
lcd_command(0x83);
string(“NOTICE BOARD”);
for(i=0;i<=13;i++)
{
while(RI==0);
b=SBUF;
RI=0;
}
lcdnewline();
string(“Command Signal”);
if((b[2]==’+’)||(b[3])==’+’)
{
if((b[3]==’C’)||(b[4])==’C’)
{
if((b[4]==’M’)||(b[5]==’M’))
{
if((b[5]==’T’)||(b[6])==’T’)
{
if((b[6]==’I’)||(b[7])==’I’)
{
lcd_command(0xC4);
string(“received”);
lcdnewline();
//delay(300);
read(“AT+CMGF=1”);
newline();
read(“AT+CMGR=1”);
newline();
newline();
//newline();
//newline();
for(l=0;l<=161;l++)
{
while(RI==0);
a[l]=SBUF;
RI=0;
}
for(l=60;l<=161;l++)
{
f=1;
if(a[l]==’a’)
{
k=0;
do
{
k++;
l++;
if(k<=20)
{
lcd_data(a[l]);
}
if((k>20) && (k<=40))
{
nextline(f);
lcd_data(a[l]);
f++;
}
if((k>40) && (k<=60))
{
nextline1(f);
lcd_data(a[l]);
f++;
}
if((k>60) && (k<=80))
{
nextline2(f);
lcd_data(a[l]);
f++;
}
} while(a[l]!=’$’);
l=162;
break;
}
//break;
}
delay(65000);
}
}
}
}
}
}  /* while end here*/
}  /* MAIN ends here*/
/* PROTOTYPE FUNCTIONS */
void lcd_command(unsigned char value)
{
chdata=value;
rs=0;
rw=0;
en=1;
delay(100);
en=0;
}
void lcd_data(unsigned char value)
{
chdata=value;
rs=1;
rw=0;
en=1;
delay(150);
en=0;
}
void read(char *ch)
{
int i;
for(i=0;ch
!=’’;i++)
{
display(ch
);
}
}
void display(char c)
{
SBUF=c;
send();
}
void send()
{
while(TI==0);
TI=0;
}
void newline()
{
SBUF=’r’;
while(TI==0);
TI=0;
SBUF=’n’;
while(TI==0);
TI=0;
}
void delay(unsigned int num)
{
unsigned int k,q;
for(k=0;k<num;k++)
{
for(q=0;q<num;q++);
}
}
void lcdnewline()
{
lcd_command(0x01);
delay(100);
lcd_command(0x02);
delay(100);
}
void serial()
{
SCON=0x50;
TMOD=0x20;
TH1=0xFD;
TR1=1;
}
void string(unsigned char *disp)
{
int x;
for(x=0;disp[x]!=0;x++)
{
lcd_data(disp[x]);
}
}
void nextline(unsigned char v)
{
if(v==1)
{
lcd_command(0XC0);
}
}
void nextline1(unsigned char v)
{
if(v==21)
{
lcd_command(0X94);
}
}
void nextline2(unsigned char v)
{
if(v==41)
{
lcd_command(0XD4);
}
}

 

 

RSS Recent Posts

  • AI algorithm for bots April 17, 2026
  • SDCC Array Access In Timer 0 Interrupt Handler April 16, 2026
  • EasyEda program has a major bug April 16, 2026
  • ANOTHER OLD PROJECT REDO April 16, 2026
  • How to set the OSCAL in a PIC 12F675 April 16, 2026

Stay Up To Date

Newsletter Signup
EngineersGarage

Copyright © 2026 WTWH Media LLC. All Rights Reserved. The material on this site may not be reproduced, distributed, transmitted, cached or otherwise used, except with the prior written permission of WTWH Media
Privacy Policy | Advertising | About Us

Search Engineers Garage

  • Engineers Garage Main Site
  • Visit our active EE Forums
    • EDABoard.com
    • Electro-Tech-Online
  • Projects & Tutorials
    • Circuits
    • Electronic Projects
    • Tutorials
    • Components
  • Digi-Key Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • Advertise