Just not getting it...
Wolfbrother
Posts: 129
So I am trying to understand the RFID/RFID test module available in the OBEX. I'm going through the manual and using serial debug to output, but I don't understand something and I think it's probably so obvious to most. In the code snippet below, I understand that time:= cnt is to make the repeat occur on entry, but I don't understand how this doesn't make the debug lines come out repeated since there looks like at least one second that the repeat should, well, repeat. But it only prints out on the screen once. How does this work?
Then I'm a bit lost on how the time += clkfreq * 2 at the end works is that adding two seconds, so when you subtract it from cnt you again have a second of repeating like before?
Sorry to be obtuse, I'm just not getting it.
Thanks in advance,
Dave
Then I'm a bit lost on how the time += clkfreq * 2 at the end works is that adding two seconds, so when you subtract it from cnt you again have a second of repeating like before?
Sorry to be obtuse, I'm just not getting it.
Thanks in advance,
Dave
time := cnt REPEAT REPEAT WHILE (cnt - time < clkfreq) ' this should get figured out.... IF (output) DEBUG.bin(output, 2) ' output shows whether a key was a match or not DEBUG.str(string(" - ")) DEBUG.dec(tag_ret) ' this is the match id, what you will pass to the main program DEBUG.tx($D) ' Carriage return for neatness REPEAT i FROM 1 TO 10 ' this little section here outputs the actual tag id IF (outtag[i] > 31) DEBUG.tx(outtag[i]) DEBUG.tx($D) ' Carriage return for neatness output := 0 ' clear output so we know when a new key has arrived time += clkfreq * 2 ' this means time = time + clkfreq*2 RFID.disable waitcnt(clkfreq + cnt) ' wait a second RFID.enable
Comments
They look like this except remove all the spaces I placed inside the brackets.
[ CODE ]
[ / CODE ]
Would it help to see the REPEAT WHILE statement looking like this:
REPEAT WHILE (cnt < (clkfreq + time))
Bruce
You may have plenty of time, but you have conditions going on there. It will only repeat if
cnt - time less than clkfreq
And it will only debug if there is output
IF (output)
Bruce
time += clkfreq * 2 time gets added to clkfreq *2 and then that value goes back into the time variable
But yes 2 secs is getting added to the time variable
Bruce
Thanks again,
Dave