This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

TRF7962A: Example code of TRF7960A

Part Number: TRF7962A
Other Parts Discussed in Thread: TRF7964A, TRF7970A

Hi,

I am working on a project to achieve ISO15693 label read and write data based on trf7962A chip. I have a hardware board that matches the example code of TRF7960EVM (sloc251). I downloaded the example code into my board. The function worked well when i tested inventory reading and writing of 15693 by using TRF7960EVMGUI which downloaded from TI's website. So now i'm learning that example code.

I found some strange problems when i was learning. I added a line of code on line 11 which is "iso_control[0] = ISO_CONTROL;", because I thought buffer "iso_control[4]" would be random if no values were set. Incomprehensibly, the reading and writing stops working when i add this line of code. Delete it and it worked well again. I double-checked and found no mistakes. 

Why it didn't work after adding this code? Expecting help.

Here is part of code:

u08_t
HostRequestCommand(u08_t *pbuf, u08_t length, u08_t broken_bits, u08_t no_crc)
{
	u08_t	index = 0, j = 0;

	u08_t	iso_control[4];
	u16_t	tx_timeout = 1, rx_timeout = 1;
	
	tx_timeout = length / 10 + 3;
	iso_control[0] = ISO_CONTROL;      // i add this
	Trf796xReadSingle(iso_control, 1);
	iso_control[0] &= 0x1F;
	if(iso_control[0] < 8)															// ISO15693
	{
		tx_timeout = tx_timeout * 1;												//ORIGINAL VALUE = 4
		rx_timeout = rx_timeout * 1;
		
		if((iso_control[0] < 2) || (iso_control[0] == 3) || (iso_control[0] == 4)) // low bit rate
        {
			tx_timeout = tx_timeout * 4;										//ORIGINAL VALUE = 4
			rx_timeout = rx_timeout * 4;
		}
		
		if(iso_control[0] % 2 == 1)													// 1 out of 256
		{
			tx_timeout = tx_timeout * 8;											//ORIGINAL VALUE = 8
			rx_timeout = rx_timeout * 1;											//ORIGINALLY NOT PRESENT
		}
	}

	rxtx_state = length; 					// rxtx_state extern variable is the main transmit counter

	*pbuf = 0x8f;
	if(no_crc == 1)
	{	
		*(pbuf + 1) = 0x90;					// buffer setup for FIFO writing WITHOUT CRC
	}
	else
	{	
		*(pbuf + 1) = 0x91;					// buffer setup for FIFO writing WITH CRC
	}
	*(pbuf + 2) = 0x3d;
	*(pbuf + 3) = rxtx_state >> 4;
	*(pbuf + 4) = (rxtx_state << 4) | broken_bits;

	if(length > 12)
	{	
		length = 12;
	}

	if(length == 0x00 && broken_bits != 0x00)
	{	
		length = 1;
		rxtx_state = 1;
	}

	Trf796xRawWrite(pbuf, length + 5);		// send the request using RAW writing

	// Write 12 bytes the first time you write to FIFO
	IRQ_CLR;								// PORT2 interrupt flag clear
	IRQ_ON;

	rxtx_state = rxtx_state - 12;
	index = 17;

	i_reg = 0x01;

	while(rxtx_state > 0)
	{	
		irq_flag = 0x00;
		while(irq_flag == 0x00)				// wait for interrupt
		{
		}
		if(rxtx_state > 9)					// the number of unsent bytes is in the rxtx_state extern
		{	
			length = 10;					// count variable has to be 10 : 9 bytes for FIFO and 1 address
		}
		else if(rxtx_state < 1)
		{	
			break;							// return from interrupt if all bytes have been sent to FIFO
		}
		else
		{	
			length = rxtx_state + 1; 		// all data has been sent out
		}									// if

		buf[index - 1] = FIFO;				// writes 9 or less bytes to FIFO for transmitting
		Trf796xWriteCont(&buf[index - 1], length);
		rxtx_state = rxtx_state - 9;		// write 9 bytes to FIFO
		index = index + 9;
	}

	rxtx_state = 1;							// the response will be stored in buf[1] upwards
	
	j = 0;
	while((i_reg == 0x01) && (j <= tx_timeout))
	{
		COUNT_VALUE = COUNT_1ms * 2;		// for TIMEOUT
		START_COUNTER;						// start timer up mode
		irq_flag = 0x00;
		while(irq_flag == 0x00)
		{
		}
		j++;
	}
	
	i_reg = 1;

	if( (((buf[5] & BIT6) == BIT6) && ((buf[6] == 0x21) || (buf[6] == 0x22)|| (buf[6] == 0x23)|| (buf[6] == 0x24) ||
		(buf[6] == 0x27)|| (buf[6] == 0x28) || (buf[6] == 0x29)|| (buf[6] == 0x2A)))
		|| (buf[5] == 0x00 && ((buf[6] & 0xF0) == 0x20 || (buf[6] & 0xF0) == 0x30 || (buf[6] & 0xF0) == 0x40))
	  )
	{	
		McuDelayMillisecond(30);					 //originally 20mSec, 100mSec seems to much
		Trf796xReset();                            //took out to see if low data rate RMB could improve
		McuDelayMillisecond(30);	
		Trf796xTransmitNextSlot();
	}  
	
	j = 0;
	while((i_reg == 0x01) && (j <= rx_timeout))
	{
		COUNT_VALUE = COUNT_1ms * 14;		// for TIMEOUT original value 14
		START_COUNTER;						// start timer up mode
		irq_flag = 0x00;
		while(irq_flag == 0x00)
        {
        }
		j++;
	}

	...
	
	}

Best regards

xubo