9780id
Junior Member level 1
- Joined
- May 8, 2013
- Messages
- 16
- Helped
- 0
- Reputation
- 0
- Reaction score
- 0
- Trophy points
- 1,281
- Activity points
- 1,386
void tx_data(unsigned char tdata)
{
TI=0;
SBUF=tdata;
while(TI==0);
}
/************************************************************************************/
void tx_string(unsigned char *tstring)
{
unsigned char i=0;
while(tstring[i]!='\0')
{
tx_data(tstring[i]);
i++;
}
}
/************************************************************************************/
unsigned char rx_data()
{
while(RI==0);
RI=0;
return(SBUF);
}
/************************************************************************************/
void enter()
{
tx_data(0x0d); // <CR>
tx_data(0x0a); // <LF>
}
void tx_data(unsigned char tdata)
{
TI=0;
SBUF=tdata;
while(TI==0);
}
/************************************************************************************/
void tx_string(unsigned char *tstring)
{
unsigned char i=0;
while(tstring[i]!='\0')
{
tx_data(tstring[i]);
i++;
}
}
/************************************************************************************/
unsigned char rx_data()
{
while(RI==0);
RI=0;
return(SBUF);
}
/************************************************************************************/
void enter()
{
tx_data(0x0d); // <CR>
tx_data(0x0a); // <LF>
}
void read_nd_check_password(unsigned char msg_array[])
{
if(Pass_array[0]==msg_array[59]&&
Pass_array[1]== msg_array[60]&&
Pass_array[2]==msg_array[61]&&
Pass_array[3]== msg_array[62])
{
display_msg();
}
else
{
SMSString("AT+CMGS=\"");
SMSString(Mob_no);
SMSString("\"\r");
delay(1);
SMSString("Password Incorrect!!");
tx0(0x1A); // Ctrl+z
delay(10);
}
If Pass_arry[0] element 0 matches with msg_array[59] element 59 and similar matches then display message else send SMS password is incorrect. Before that it is reading the SMS and msg_array[] contains the SMS. element 59 to 62 of msg_array[] contains the password. For serial interrupt refer to book "The 8051 Microcontroller and Embedded System Using Assembly and C" by Muhammed Ali Mazidi.
https://www.8051projects.info/resources/a-rewrite-of-the-serial-example-to-use-interrupts-in-c.60/
https://saeedsolutions.blogspot.in/2012/05/interfacing-with-uart-of-8051.html
Code C - [expand] 1 2 3 4 5 6 7 8 9 10 11 12 13 unsigned int i = 0; void serial (void) interrupt 4 // giving the interrupt priority { i f (RI == 1) // it was a receive interrupt { msg_array[i++] = SBUF; msg_array[i] = '\0'; RI = 0; TI = 1; } }
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?