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.

Example code for read/writing user memory

Other Parts Discussed in Thread: TRF7970A

I currently have the DLP Design TRF7970A BoosterPack and have it working on an F5172 microcontroller. I can read tag UIDs correctly. The next stage however is to read/write user memory on a tag( NTAG213, ISO 14443A )


Does the current example code support this? Or do I have to use NFCLink?

Thanks!

  • this code was written for the TRF7970A BoosterPack, for the -G2xx LP...but you could use it i think since you have gotten this far on an -F5xx

    see function called NFC_TYPE2_WRITE_BLOCK, in iso14443a.c file

    and the attached presentation. 

    code ==> 4011.TRF7970ABP_Project_10_24_2014.zip

    presentation ==> 5824.NFC Forum Type 2 Tag Platform Operations with TRF7970A_02_18_2014.pdf

  • Thanks for the quick reply Josh.. I'll work on it and report back.

  • Hi Josh,

    I think there is something wrong in the data dump into the UART host at the end of the NFC_TYPE2_WRITE_BLOCK function. Please correct me if I'm wrong.

    We need the block that was written in to be displayed on the host terminal.
     Is that correct? In that case we would need to display 4 bytes buf[7] onwards.

    BTW I was able to write to the tag. Thanks!

    void NFC_TYPE2_WRITE_BLOCK(void) //test function on one block for now (01/27/2014, JDW)
    {
    	u08_t	i = 1, j = 0;
    	u16_t	k;
    
    	buf[0] = ISO_CONTROL;
    	buf[1] = 0x88;							//to RX with CRC
    	Trf7970WriteSingle(&buf[0], 2);
    
    	buf[0] = SPECIAL_FUNCTION;			//to enable 4-bit RX
    	buf[1] = 0x04;							//setting bit 2 in register 0x10
    	Trf7970WriteSingle(&buf[0], 2);
    
    	buf[0] = 0x8F;							//Reset FIFO
           buf[1] = 0x91;							//Send with CRC
           buf[2] = 0x3D;							//Write Continuous
           buf[3] = 0x00;							//upper and middle nibbles of # of bytes going to FIFO
           buf[4] = 0x60;							//lower nibble # and broken # of bytes going to FIFO (in this case 2 complete bytes are going to be transmitted)
    	buf[5] = 0xA2;							//Write Command
    	buf[6] = 0x03;							//Block # (called Bno) to write
    	buf[7] = 0xE1;							// for Type 2 NDEF formatting, using on Page 3: E1:10:12:00 (Mifare Ultralight C) or E1:11:12:10 (Mifare Ultralight) THIS IS OTP BLOCK!
    	buf[8] = 0x10;							//										Page 4: 01:03:A0:10
    	buf[9] = 0x12;							//										Page 5:	44:03:00:FE (blocks 3, 4 & 5 required to be considered NDEF formatted and empty)
    	buf[10] = 0x00;							//
    
    
        rxtx_state = 1;
    
        Trf7970RawWrite(&buf[0], 11);
    
        IRQ_CLR;								// PORT2 interrupt flag clear
    	IRQ_ON;
    
    	//ISO14443IRQWaitTimeout(5,50);
    
    	i_reg = 0x01;
    	irq_flag = 0x00;
    	START_COUNTER;										//	Starting Timeout
    
    	while(irq_flag == 0x00)
    	{
    	}													// wait for end of TX interrupt
    	RESET_COUNTER;
    
    	McuCounterSet();									// TimerA set
    	COUNT_VALUE = COUNT_1ms * 20;
    	START_COUNTER;										// start timer up mode
    
    	irq_flag = 0x00;
    
    	while(irq_flag == 0x00)
    	{
    	}													// wait for interrupt
    	RESET_COUNTER;
    
    
    
    
    
    	while(i_reg == 0x01)								// wait for RX complete
    	{
    		k++;
    
    		if(k == 0xFFF0)
    		{
    			i_reg = 0x00;
    			rx_error_flag = 0x00;
    
    		}
    	}
    
    	if( i_reg == 0xFF)
    		{		// if received block data in buffer
    		if(stand_alone_flag == 1)
    		{
    			//found = 1;
    			#ifdef ENABLE_HOST
    			for(j = 0; j < 7; j++){
    				UartSendCString("NFC Type2 Block ");
    				//UartPutByte(ui8StartBlock++);
    				UartSendCString(":  [");
    				for(i = 1+(j*4); i < 5+(j*4); i++)
    				{
    					UartPutByte(buf[i]);		// send block data to host
    				}
    				UartPutChar(']');
    				UartPutCrlf();
    			}
    
    			#endif
    		}
    	}
    
    }