This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

reentrant

i am using an 89v51rd2 controller with out external RAM, i use the following reentrant function for one of the functionalities, i cant avoid it because this function can be recursively called any no of times,

void reentrantfunction(unsigned char data1, unsigned char data2) compact reentrant
{ unsigned char local1, local2 = 0;

if(data2) statements;

switch(data2) { case 0: ……. break; ………… case 5: ….. break; } Function2();

for(local1=0; (local1<25); local1++) { Function3();

if(global1) { Global2[local2] = local1; local2++; } Global3 = xx; Function4(); } If (Local2) { Global4 +=1;

for(data2=0;data2<local2;data2++) { Rentrantfuncion (global2 [data2],global4); } Global4 -=1; }
}

this is how my startup file stack initialization looks like..

IBPSTACK EQU 0
IBPSTACKTOP EQU 0FFH+1

XBPSTACK EQU 0
XBPSTACKTOP EQU 0FFFFH+1

PBPSTACK EQU 1
PBPSTACKTOP EQU 02FFH+1

i am having problems with this function, the speed for now is not a concern but the functionality itself goes wrong somewhere.. does the code ring bells to anyone ??

Parents
  • hie all,

    this is actually the base code of a card reader.

    a set of commands are sent to a bunch of cards to read their unique ids. this is an anticollision mechanism prescribed for the cards by ISO.

    basically only one card replies at a time dependin on its unique iD. when we send a set of commands to the cards, only cards with matching numbers reply. if two cards reply at the same time, their LSB nibbles are the same and we ought to send the command again masking the LSB nibble to identify from the next nibble. this can go on for 8 nibbles at the most.

    we need to keep calling the function again and again till there are no unread cards.

    pray my english is okay so you understand atleast the jist of it or you could google a document numbered '17n1692t' for more details.

Reply
  • hie all,

    this is actually the base code of a card reader.

    a set of commands are sent to a bunch of cards to read their unique ids. this is an anticollision mechanism prescribed for the cards by ISO.

    basically only one card replies at a time dependin on its unique iD. when we send a set of commands to the cards, only cards with matching numbers reply. if two cards reply at the same time, their LSB nibbles are the same and we ought to send the command again masking the LSB nibble to identify from the next nibble. this can go on for 8 nibbles at the most.

    we need to keep calling the function again and again till there are no unread cards.

    pray my english is okay so you understand atleast the jist of it or you could google a document numbered '17n1692t' for more details.

Children