| Mahesh Joshi 06/20/09 06:52 Read: 161 times Mumbai India |
#166284 - Why dont you define correct id in "code" space Responding to: Popa Valentin's previous message |
Dear Popa,
Why dont you define the valid id in code space instead of data space.
// #include <REGX52.h> //program care stocheaza si compara(bun)
#include <89lpc932.h>
#define Baud_rate 0xF4
#define LED_P P2_0
#define LED_OF 1
#define LED_ON 0
code unsigned char valid_id[10] = {0x30, 0x34, 0x31, 0x35, 0x44, 0x38, 0x41, 0x31, 0x46, 0x31};
//rx_on, & chk_id can also be defined as bit(if compiler permits it)
unsigned char offset, rx_on, chk_id;
unsigned char com_rx_buf[11];
void serial_IT(void) interrupt 4 using 1
{
unsigned char ch;
if(RI)
{
if(rx_on)
{
if(SBUF == 0x0D)
{
chk_id = 1;
rx_on = 0;
}
else
{
if(offset < 10)
{
com_rx_buf[offset] = SBUF;
offset++;
}
else
rx_on = 0;
}
}
else
{
if(SBUF == 0x0A)
{
rx_on = 1;
for(ch = 0; ch < 11; ch++)
com_rx_buf[ch] = 0x00;
offset = 0;
}
}
}
else
{
if(TI)
TI = 0;
}
}
void init_var(void)
{
unsigned char ch;
for(ch = 0; ch < 11; ch++)
com_rx_buf[ch] = 0x00;
offset = 0;
rx_on = 0;
chk_id = 0;
}
void init(void)
{
TMOD = 0x20;
SCON = 0x50;
TH1 = Baud_rate;
TL1 = Baud_rate;
// EA = 1;
ES = 1;
TR1 = 1;
init_var();
LED_P = LED_OF;
}
void compare_id(void)
{
unsigned char ch;
if(offset == 10)
{
for(ch = 0; ch < 10; ch++)
{
if(com_rx_buf[ch] != valid_id[ch])
break;
if(ch == 9)
LED_P = LED_ON;
}
}
}
void main(void)
{
EA = 0;
init();
EA = 1;
while(1)
{
if(chk_id)
{
compare_id();
init_var();
}
}
}
Regards, Mahesh |
| Topic | Author | Date |
| Project using 89s52 | Popa Valentin | 05/25/09 04:41 |
| RET (Where?) | Mahesh Joshi | 05/25/09 06:16 |
| Loops? | Per Westermark | 05/25/09 06:20 |
| Loops? | Popa Valentin | 05/25/09 07:46 |
| with a quick glance | Erik Malund | 05/25/09 07:53 |
| with a quick glance | Popa Valentin | 05/25/09 07:59 |
| search for ... | Erik Malund | 05/25/09 08:55 |
| Loops Something like this | Mahesh Joshi | 05/26/09 01:16 |
| School work? | Per Westermark | 05/26/09 03:49 |
| Nope | Mahesh Joshi | 05/26/09 05:08 |
| Loops Something like this | Popa Valentin | 05/26/09 03:52 |
| ?...Doesnot Work...? | Mahesh Joshi | 05/26/09 04:16 |
| ?...Doesnot Work...? | Popa Valentin | 05/26/09 04:38 |
| Correct | Mahesh Joshi | 05/26/09 05:14 |
| You sure you get a line feed before RFID? | Per Westermark | 05/26/09 05:35 |
| You sure you get a line feed before RFID? | Popa Valentin | 05/26/09 05:41 |
| Try This | Mahesh Joshi | 05/26/09 06:03 |
| Try This | Popa Valentin | 05/26/09 11:04 |
| error | Popa Valentin | 05/28/09 03:13 |
| it's bible time | Erik Malund | 05/28/09 06:28 |
| it's bible time | Popa Valentin | 05/28/09 06:59 |
| Is it ERROR or DOUBT??? | Mahesh Joshi | 05/28/09 06:31 |
| Is it ERROR or DOUBT??? | Popa Valentin | 05/28/09 07:01 |
| Compare | Popa Valentin | 06/01/09 01:18 |
| Simulate your function. | David Prentice | 06/01/09 03:00 |
| Simulate your function. | Popa Valentin | 06/01/09 03:19 |
| Use the free Keil C compiler Evaluation | David Prentice | 06/01/09 06:16 |
| COMPARE | Mahesh Joshi | 06/02/09 04:41 |
| compare | Popa Valentin | 06/02/09 09:09 |
| Still not out of time for C | Per Westermark | 06/02/09 10:06 |
| Still not out of time for C | Popa Valentin | 06/15/09 07:26 |
| Read up on pointer | Per Westermark | 06/15/09 08:57 |
| Read up on pointer | Popa Valentin | 06/15/09 09:06 |
| Me or you? | Per Westermark | 06/15/09 10:04 |
| Or do not use a pointer | Maarten Brock | 06/20/09 03:22 |
| working code | Popa Valentin | 06/20/09 05:03 |
| Describe your work process | Per Westermark | 06/20/09 05:45 |
| v | Popa Valentin | 06/20/09 06:00 |
| Did you read? Did you debug? | Per Westermark | 06/20/09 06:23 |
| Why dont you define correct id in "code" space | Mahesh Joshi | 06/20/09 06:52 |
| Hoping to get someone relegated? | Per Westermark | 06/20/09 07:27 |
| Reading or Transmitting Data | Mahesh Joshi | 05/25/09 06:55 |
| Reading or Transmitting Data | Popa Valentin | 05/25/09 07:37 |
| a trip to the wild blue younder | Erik Malund | 05/25/09 07:17 |
| This is where it gets lost | Richard Erlacher | 05/25/09 08:07 |
| The fundamental problem is... | Jez Smith | 05/27/09 08:24 |
| Same as its always been, | Andy Neil | 05/27/09 08:54 |
| Yep I cannot think | Jez Smith | 06/01/09 03:20 |
| Yep I cannot think | Popa Valentin | 06/01/09 04:04 |
| Why too late? | Per Westermark | 06/01/09 04:22 |
| for a simple task ... | Richard Erlacher | 06/22/09 10:50 |
| More than one way to skin a cat | Per Westermark | 06/22/09 11:18 |
| my $0.02 | Erik Malund | 06/22/09 13:27 |
If you can not code it in ASM ... | Richard Erlacher | 06/22/09 19:04 |



