| Mahesh Joshi 05/26/09 01:16 Read: 258 times Mumbai India |
#165587 - Loops Something like this Responding to: Popa Valentin's previous message |
Dear Popa,
Note: This is not the only way. Also this may not be perfect. But it should give you some idea. ;considor following
;I am storing received bytes at RAM address 0x40 onwards pointed by R0
;bit 00h indicates reception is going on
Valid_ID: DB 30h,34h,31h,35h,44h,38h,41h,31h,46h,31h ;Is this correct???
;this is a valid tag ID
RX_ID: ds 10 ;ONLY IF I DONT HAVE COMPLETE COMMAND OVER CODE
AJMP START
START: MOV TMOD,#20h
MOV SCON,#50h
MOV TH1,#0F4h ;UART is configured for desired BAUD
MOV TL1,#0F4h
MOV SP, #60h ;Initialise Stack Pointer
SETB TR1 ;Run T1 for BAUDRATE Generation
;If I have total command over program I will do something like this
MOV R0,#40h ;init counter
;If I dont have total command then I will do something like this
MOV R0,#RX_ID
SETB P2.0 ;the LED must be in off state
WAIT_RX:
JNB RI, WAIT_RX
MOV A, SBUF
MOV R2, A
CLR RI
CJNE A,#0Dh,READ_NXT
ACALL COMPARE
SJMP WAIT_RX
READ_NXT:
CJNE A, #0Ah, START_RX
SETB 00h
SJMP WAIT_RX
START_RX:
JNB 00h, WAIT_RX
CJNE R0, #4Ah, NO_SAVE ;or CJNE R0, #RX_ID + 0Ah, NO_SAVE
MOV @R0, A
NO_SAVE:
INC R0
SJMP WAIT_RX
COMPARE:
CJNE R0, #4Ah,NO_MATCH ;or CJNE R0, #RX_ID + 0Ah, NO_MATCH
;if total bytes received in not 10 then mismatch
MOV R2,#00h
MOV R0,#40h ;or MOV R0,#RX_ID
MOV DPTR,#Valid_ID
CMP_NXT:
MOV A,R2
MOVC A,@A+DPTR
CJNE A,@R0,NO_MATCH
INC R0
INC R2
CJNE R2,#0Ah,CMP_NXT
CLR P2.0 ;GLOW LED
NO_MATCH:
CLR 00h
RET
END
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 |



