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.

[RF430CL331H] Host firmware

Guru 24520 points
Other Parts Discussed in Thread: RF430CL331H, MSP-EXP430F5529LP

Hi TI Experts,

Please let me confirm the host controller firmware for RF430CL331H.

[Question]

The system (It is used the RF430CL331H) will send the data less than the data size which PCD requested. How should do the host MCU of RF430CL331H?

According to the sample code as below(red line), it seems that host mcu will write the actually send data size to the NDEF_BLOCK_LENGTH register. Is my understanding correct? Is there any other required handling in this case? 

******************************

case FILE_REQUEST_STATUS:
{
uint16_t buffer_start;
uint16_t file_offset;
uint16_t file_length;
buffer_start = Read_Register(NDEF_BUFFER_START); // where to start writing the file info in the RF430 buffer (0-2999)
file_offset = Read_Register(NDEF_FILE_OFFSET); // what part of the file to start sending
file_length = Read_Register(NDEF_FILE_LENGTH); // how much of the file starting at offset to send
// we can send more than requested, called caching
// as long as we write back into the length register how
// much we sent it
interrupt_serviced |= DATA_TRANSACTION_INT_FLAG; // clear this flag later
// can have bounds check for the requested length
file_length = SendDataOnFile(SelectedFile, buffer_start, file_offset, file_length);

Write_Register(NDEF_FILE_LENGTH, file_length); // how much was actually written
Write_Register(INT_FLAG_REG, interrupt_serviced); // ACK the flags to clear
Write_Register(HOST_RESPONSE, INT_SERVICED_FIELD); // indicate that we have serviced the request

break;
}

******************************

If you have any questions, please let me know.

Best regards.

Kaka

  • There may be some cases where the example host controller firmware will send less data out than is requested.

    For now in the SendDataOnFile function, comment out the code as shown:

    uint16_t SendDataOnFile(uint16_t selectedFile, uint16_t buffer_start, uint16_t file_offset, uint16_t length)
    {
        uint16_t ret_length;
        uint16_t file_length;

        file_length = (((uint16_t)NdefFiles[selectedFile].FilePointer[0]) << 8) + NdefFiles[selectedFile].FilePointer[1];  // reads the NLEN of the file

        // make sure we are not sending above the length of the file (the send data early feature above does not do file length check)
        // if reader requests data we can expect that it is the correct length
        //    if (file_length < (file_offset + length))
        //    {
        //        length = file_length - file_offset;  //difference of two, sends two less bytes
        //    }

    However if the data is sent in advance using this line of code:

    file_length = SendDataOnFile(SelectedFile, buffer_start, file_offset, AMOUNT_DATA_TO_SENT_EARLY); //255 is enough for atleast one packet


    the host controller will send out more data than needed.  This is due to the AMOUNT_DATA_TO_SENT_EARLY is a fixed value.
    It is not checking the file length here and it may send data that is past the end of the file.

    If the "Extra Data" early feature is not used, then the commenting will fix the problem.


    We are working on a fix for this.

  • Hi Alex,

    Thank you for your response.

    I checked your comment but I could not understand correctly.

    Would you please re-explain the way (how does customer porting the firmware on host mcu?) in detail in order to send the less data?

    Also would you please teach me the "Extra Data" early feature in detail? What is this?

    Best regards.
    Kaka

  • The line of code:

    Write_Register(NDEF_FILE_LENGTH, file_length); // how much was actually written

    Indicates to the RF430CL331H how much data was sent over I2C.

    Kaka said:
    Would you please re-explain the way (how does customer porting the firmware on host mcu?) in detail in order to send the less data?

    I am not sure I am clear on this question.  Why would you like to send less data?  It is against the NFC specification to send less data then is requested.

    Kaka said:
    Also would you please teach me the "Extra Data" early feature in detail? What is this?

    The best explanation for this is to read the RF430CL331H datasheet : http://www.ti.com/lit/gpn/rf430cl331h

    Read section: NDEF or Capability Container Read Procedure (Prefetch Feature)

  • Hi

    Now, customer are thinking to use this device for firmware update of their system. And their system will check the firmware before updating their system. So, PCD read the existing firmware data on their system via NFC. In my understanding, PCD(like smartphone) requests the send data size to Tag(RF430CL331H). But PCD does not know the firmware data size on the system which Tag used. So, there is a potential that Tag will sent the less data than PCD requested.
    Is my understanding correct?

    > It is against the NFC specification to send less data then is requested.

    According to your application note, it seems that the less data than host required is permitted.
    *********************
    www.ti.com/.../sloa208.pdf

    Le – Expected Response Length, this byte signifies the maximum number of Data Bytes should be
    sent back in the response. The tag cannot send back more bytes than Le specifies, but it is permitted
    to send back less bytes.
    *********************
    Is this my misunderstanding?

    If you have any question, please let me know.
    Best regards.
    Kaka
  • For the RF430CL331H the host controller determines how much data is sent back.  And for the host controller, the user writes the program used and therefore how much data is sent back.  The user is in control of this.

    The reason is that the RF430CL331H does not hold the entire NDEF message, rather it always requests the data from the host controller on demand when requests come from the PCD.  The host controller (user's code) writes the part of the message into the RF430CL331H and then writes to the NDEF_FILE_LENGTH how much it actually sent.

    One other suggestion is that the firmware length can be stored in a header in the beginning of the NDEF message.  The PCD will be able to read this and know exactly the length of the firmware.

  • Hi Alex,

    Thank you for your answers.
    Summary your comments, host controller determines how much data is sent back. So ,host mcu writes to the NDEF_FILE_LENGTH how much it actually sent. Customer can refer the following method.
    **************
    Write_Register(NDEF_FILE_LENGTH, file_length); // how much was actually written
    **************

    Is there any other necessary handling in order to implement the customer's requirement?

    Best regards.
    Kaka
  • Please refer to the example project with firmware that demonstrates transmitting an NDEF message on the MSP-EXP430F5529LP launchpad:

    http://www.ti.com/lit/zip/sloc330

    Keep in mind the firmware change that I mentioned earlier.

  • >Keep in mind the firmware change that I mentioned earlier

    Does this mean as below?
    ************
    There may be some cases where the example host controller firmware will send less data out than is requested.

    For now in the SendDataOnFile function, comment out the code as shown:

    uint16_t SendDataOnFile(uint16_t selectedFile, uint16_t buffer_start, uint16_t file_offset, uint16_t length)
    {
    uint16_t ret_length;
    uint16_t file_length;

    file_length = (((uint16_t)NdefFiles[selectedFile].FilePointer[0]) << 8) + NdefFiles[selectedFile].FilePointer[1]; // reads the NLEN of the file

    // make sure we are not sending above the length of the file (the send data early feature above does not do file length check)
    // if reader requests data we can expect that it is the correct length
    // if (file_length < (file_offset + length))
    // {
    // length = file_length - file_offset; //difference of two, sends two less bytes
    // }

    However if the data is sent in advance using this line of code:

    file_length = SendDataOnFile(SelectedFile, buffer_start, file_offset, AMOUNT_DATA_TO_SENT_EARLY); //255 is enough for atleast one packet

    the host controller will send out more data than needed. This is due to the AMOUNT_DATA_TO_SENT_EARLY is a fixed value.
    It is not checking the file length here and it may send data that is past the end of the file.

    If the "Extra Data" early feature is not used, then the commenting will fix the problem.
    We are working on a fix for this.
    ******************

    Best regards.
    Kaka
  • Yes, that is the change that I was referring to.
  • Hi Alex,

    > If the "Extra Data" early feature is not used, then the commenting will fix the problem.
    >We are working on a fix for this.

    Did you fix this problem?

    Best regards.
    Kaka
  • This has not been done yet. There is currently no estimated time until done.

    The
    if (file_length < (file_offset + length))
    {
    length = file_length - file_offset; //difference of two, sends two less bytes
    }
    is producing a result that is two bytes in error. This has to be investigated and corrected. Probably in the same code section.

    Also if the file is updated by the NFC reader, the file_lenght is not changed. To maintain a correct file_length value, the host controller has to monitor the file update and update the correct file_length when it is changed.

    Alex