Automotive and Embedded Networks

cancel
Showing results for 
Search instead for 
Did you mean: 

I2C Non-standard Read Command

Hi all!

 

I've been working with the USB-8451 for a while and now I'm trying to communicate with an Atmel AT88SCXX memory but I'm having a hard time. Maybe someone had already a similar problem and can help me out. This is my situation: I'm developing a program to communicate with the AT88SCXX memory (crypto memory) by using the I2C interface of a USB-8451. Unfortunately, the Read command for this memory does not comply with the I2C Philips standard because it requires a "0" bit in the LSB of the first byte so when I try to use any of the read commands provided for the NI-8451 I got an error message. Somehow I need to develop a customized command sequence with the output similar to the one shown in the picture attached and my software should capture the returned bytes.

This is:  

 

start--Dev Address-LSB=0--- Word Addr1 ---Word Addr2 ---Parameter N---- Returned byte1------ Returned byte1-----........Returned byteN ----Stop 

(after every byte sent or received memory returns and acknoledge except for the last returned byte) 

 

Where Parameter N is the number of bytes I want to read, Word Addr1 and 2 depend on the user zone I want to access. I’m kind of stuck with this read command so any help will be appreciated. I'm using Labwindows/CVI 8.2. 

Thanks, 

 

  MemRead I2C

 

0 Kudos
Message 1 of 3
(6,934 Views)

Howdy giogonza,

 

Thanks for posting the image to the forum, that helps out a great deal.  From reading your post however, it seems that you need to change the Address type instead of the acutal read command.  This is good because the read command is handeled directly through the I2C driver and cannot be modified.  I think you should try the I2C Script Address + Read.vi located in the Advanced I2C pallette.  The detailed help for his VI will show you how to specifically configure your address to have a LSB of 0 so that you can communicate with your device.  Let me know if you have any problems with this or if it indeed solves your problem.  Thanks, and have a great day!

Sincerely,

Chris G in AE
0 Kudos
Message 2 of 3
(6,916 Views)

Hello Chris G!

Thank you for your suggestion. Certainly I fixed my problem today. You were partially right, I solved the problem by using the advanced script commands for the USB-8451. I modified the General I2C Write script example that came with the device by adding a read sequence just before the generation of the stop signal. The code looks like this:

 

 /* issue start condition */
          errChk (ni845xI2cScriptIssueStart (ScriptHandle));

          /* write 7-bit address and direction bit 0 (write) */
          errChk (ni845xI2cScriptAddressWrite (ScriptHandle, Address));

          /* Write the I2C Data */
          errChk (ni845xI2cScriptWrite(ScriptHandle, WriteSize, SendData));

          /* issue delay */
          //errChk (ni845xI2cScriptDelay (ScriptHandle, Delay));
   
    /* Read Data back from memory */
    errChk(ni845xI2cScriptRead (ScriptHandle, NumBytesRead, 1, &ScriptReadIndex));  // <----------I added this line
    
    /* issue stop condition */
          errChk (ni845xI2cScriptIssueStop (ScriptHandle));

          /* issue delay */
          errChk (ni845xI2cScriptDelay (ScriptHandle, Delay));
        
          }

         /* run the script */
         errChk (ni845xI2cScriptRun (ScriptHandle, DeviceHandle, PortNumber));
  
   /* extract the read data */
         errChk (ni845xI2cScriptExtractReadData (ScriptHandle, ScriptReadIndex, ReadData));  // <----------I added this line to retrieve the data

         /* close the Script Handle*/
         errChk (ni845xI2cScriptClose (ScriptHandle));
         ScriptHandle = 0;
  
   /* Fill Table with data retrieved from Memory */
   SetTableCellRangeVals (panelHandle, PANEL_DATATABLE, MakeRect (1, 2, NumBytesRead, 1),   //<----------I added this line to populate a table
                            ReadData, VAL_COLUMN_MAJOR);

 

The phylosophy is exactly the same if you are using labview to code this program.

The command is a combination of the write and read I2C commands. Now I'm able to read the content of the memory by using this non-standard command.

 

Thanks a lot for your help and for taking the time to look into this!

 

Beast regards,

-Giovanni-

 

0 Kudos
Message 3 of 3
(6,911 Views)