RFID RDM630 and PSOC4 pioneer kit-042

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
lock attach
Attachments are accessible only for community members.
Anonymous
Not applicable

Hey guys, I'm designing authentication control system with rfid keys. And I stacked with one issue - rfid reader is connected with UART and it causes non-stop stream of received data. I've decided to solve that with making a flag that UartGetChar works only if  correct key haven't been founded, but it works just with right key I need the same limit for incorrect key, because non-stop stream is bad idea to work with. I tried to make flag that changes state after arrays were compared, but it works incorrectly, first comparison is good but while array is forming second time in array first 7 elements are empty spaces and output looks like this  -
Access granted! Card Number: 09008B316BD8
Time ran out!
Access denied! Card Number:
Time ran out!
Access denied! Card Number:
Time ran out!
Access denied! Card Number:
Time ran out!

   

And it doesn't matter what key I check, true or false it makes the same output.

0 Likes
4 Replies
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

Your timer is running free and will generate an interrupt where you reset some variables. This can invalidate your wanted flow of program.

   

More: As a general rule: Every global variable (those declared outside of a function)  that are changed within an interrupt handler must have the "volatile" attribute!!! This will not yet change program behave, but when compiler optimization is turned on it will!!

   

 memset(arr, 0, strlen(arr)); //way to avoid that symbol and store correct data in array

   

Why strlen and not the size of the array, this might go wrong under some circumstances.

   

Increase the size of arr to prevent overwriting of variables in case of bad transmission ('\003' not seen)

   

Consider declaring global "ind" variable as  local static and care for never overflowing buffer sizes.

   

 

   

Bob

0 Likes
Anonymous
Not applicable
        Thanks, but how I should use timer and interrupt handler function in that case correctly. And another question, it is possible to make few interrupt handler functions that work with one interrupt block?   
0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

is it possible to make few interrupt handler functions that work with one interrupt block?

   

No need to. You can put the code of all handlers into one function or call each of the required sub-functions from the (one and only) handler.

   

how I should use timer and interrupt handler function in that case correctly?

   

Imagine what you want: From a certain point on you will allow for one second to get all your information transmitted.

   

So you will have to stop your timer, re-load with zero (when you count up) and start the timer. When transmission is done, you stop the timer. When the timer runs out you have to stop it, too and set a global (volatile!) flag to show the situation.

   

 

   

Bob

0 Likes
Anonymous
Not applicable

Firstly my aim was to start timer after key is accepted or declined, count to 5 sec and close door(change accepted flag to opposite) what means that now it is possible to collect new data to our array and check it again. And my problem is in setting that limit for receiving data after I compared keys. I know how to make it just if correct key was found - replace if(!compared) with if(!accepted).

0 Likes