Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
Popa Valentin
05/25/09 04:41
Read: 1417 times
Timisoara
Romania


 
#165575 - Project using 89s52
Hello guys!I am a newcomer in the area of microcontroller but i have to do a project using 89s52 .It's about controlling the access of an automobile in a parking area. I have at my disposal a Parallax Rfid card reader, a servo motor Futaba s3003,the 89s52 uC integrated on a EEDT 5.0 board.
I've connected the rfid to the uC and wrote a code that is supposed to get a tag ID from the reader,compare it with a tag ID kept in memory and if the two ID's are the same to make a LED glow.But it's not working.If there is anybody that can help me figure out what is wrong with my code please don't hesitate to reply to this thread.
Many thanks!
COUNTER:DS 1

RECEIVED BIT 00h              ;this is the bit that confirms the receival of 10 bytes
VALID_TAG BIT 01h             ;this is the bit that confirms the receival of a valid tag
BYTE: DS 10                   ;in this variable i will store the values of the incoming bytes
BYTES: DB 30h,34h,31h,35h,44h,38h,41h,31h,46h,31h   ;Is this correct???
                                                     ;this is a valid tag ID

AJMP START
        
START:  MOV TMOD,#20h
        MOV SCON,#50h
        MOV TH1,#0F4h
        MOV TL1,#0F4h
        SETB TR1

        MOV COUNTER,#01h    ;init counter
        CLR RECEIVED
        CLR VALID_TAG
        SETB P2.0                ;the LED must be in off state

FIRST_BYTE:     JB TI,TRANS      ;if transmission is over jump to trans
                MOV A,SBUF
                CJNE A,#0Ah,LAST_BYTE   ;check first byte
                MOV COUNTER,#01h
                AJMP RECEV

LAST_BYTE:      CJNE A,#0Dh,SEC_BYTE     ;check 12-th byte
                 MOV COUNTER,#01h
                AJMP RECEV

SEC_BYTE:       MOV R1,COUNTER            ;second byte
                CJNE R1,#01h,TRD_BYTE
                MOV BYTE,A
                AJMP INC

TRD_BYTE:       CJNE R1,#02h,FRTH_BYTE    ;third byte
                MOV BYTE+1,A
                AJMP INC

FRTH_BYTE:      CJNE R1,#03h,FIFTH_BYTE   ;fourth byte    
                MOV BYTE+2,A
                AJMP INC

FIFTH_BYTE:     CJNE R1,#04h,SIXTH_BYTE     ;fifth byte
                MOV BYTE+3,A
                AJMP INC

SIXTH_BYTE:       CJNE R1,#05h,SEVENTH_BYTE  ;sixth byte
                MOV BYTE+4,A
                AJMP INC

SEVENTH_BYTE:       CJNE R1,#06h,EIGHT_BYTE   ;seventh byte
                MOV BYTE+5,A
                AJMP INC

EIGHT_BYTE:       CJNE R1,#07h,NINTH_BYTE     ;eight byte  
                MOV BYTE+6,A
                AJMP INC

NINTH_BYTE:       CJNE R1,#08h,TENTH_BYTE     ;ninth byte
                MOV BYTE+7,A
                AJMP INC

TENTH_BYTE:       CJNE R1,#09h,ELEVENTH_BYTE  ;tenth byte
                MOV BYTE+8,A
                AJMP INC

ELEVENTH_BYTE:       CJNE R1,#0Ah,INC         ;eleventh
                MOV BYTE+9,A
                SETB RECEIVED
                AJMP INC       

INC:    INC COUNTER

RECEV:  CLR RI
        RET

TRANS:  CLR TI
        RET

CHECK:  JB RECEIVED,COMPARE         ;if we received a 10 bytes tag ID jump to compare
        RET

COMPARE:        MOV A,BYTES       ;compare the content of what we received with what we have in memory
                CJNE A,BYTE,FGG    ;the comparisson is done at a byte-by-byte level
                MOV A,BYTES+1
                CJNE A,BYTE+1,FGG
                MOV A,BYTES+2
                CJNE A,BYTE+2,FGG
                MOV A,BYTES+3
                CJNE A,BYTE+3,FGG
                MOV A,BYTES+4
                CJNE A,BYTE+4,FGG
                MOV A,BYTES+5
                CJNE A,BYTE+5,FGG
                MOV A,BYTES+6
                CJNE A,BYTE+6,FGG
                MOV A,BYTES+7
                CJNE A,BYTE+7,FGG
                MOV A,BYTES+8
                CJNE A,BYTE+8,FGG
                MOV A,BYTES+9
                CJNE A,BYTE+9,FGG
                SETB VALID_TAG

FGG:    RET

LED_CHECK:      JB VALID_TAG,GLOW_LED   ;if tag ID is a valid tag then make a LED glow
                RET

GLOW_LED:       CLR P2.0
                SJMP GLOW_LED

END

 





List of 54 messages in thread
TopicAuthorDate
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      

Back to Subject List