AnsweredAssumed Answered

How to use LDD?

Question asked by Oleg Lavrukhin on Oct 14, 2014
Latest reply on Oct 16, 2014 by Oleg Lavrukhin

Hello, community! i am beginner for FRDM-k64F, CW 10.6 and Processor Expert. At first, i try to read registers from build-in  FXOS8700CQ via I2C and print it to console. I use CPU clock as default, then i added I2C_LDD component, configure it as MASTER with: interrupt=enable, address mode=7-bits, Target slave address init=0x1d, SDA pin=PTE25, SCL pin=PTE24, internal freq.=47.98 Mhz, Bits 0-2 =010, Bits 3-5 =100, SCL freq = 214.235 kHz, autoinit=Yes. Then i make a code as "Help on component" for reading 16 bytes from SLAVE from register address=0x00, and added a procedure, which printed in console Error code:


void print_error(uint8_t err_type)




  case 0x00U: printf("ALL OK \n"); break;

  case 0x07U: printf("Device is disabled \n"); break;

  case 0x01U: printf("ERR_SPEED\n"); break;

  case 0x08U: printf("The master device is busy\n"); break;

  case 0x81U: printf("Stop condition isn't possible generated on end transmission\n"); break;

  case 0x8DU: printf("ERR_PARAM_ADDRESS_TYPE -  Invalid address type\n"); break;

  case 0x89U: printf("ERR_PARAM_ADDRESS Invalid address value\n"); break;

  case 0x09U: printf("Requested value or method not available\n"); break;






LDD_TDeviceData *My_IIC_Ptr;

LDD_TError Error;

uint8_t TX_buff[1];

uint8_t RX_buff[16];


  Error= CI2C1_MasterSendBlock(My_IIC_Ptr, (uint8_t *) TX_buff, 1, LDD_I2C_NO_SEND_STOP);// send to FXOS8700CQ register =0

  Error= CI2C1_MasterReceiveBlock(My_IIC_Ptr, (uint8_t *) RX_buff, 16, LDD_I2C_SEND_STOP);// read registers 0x00-0x0F from FXOS8700CQ 




In the DEBUG after execution "CI2C1_MasterReceiveBlock", I get "error=0x08", "The master device is busy", and input buffer RX_buff contains 0x00.

if I added in code checking  "DataReceivedFlg" and "DataTransmittedFlg" (as in "Help"), program enters an infinite loop, because it is not an event occurs (I2C2_OnMasterBlockSent or I2C2_OnMasterBlockReceived) .

my questions:

1) Do I Need added "PinSetting" component if i already added I2C_LDD ?

2) why I do not see the processing of an event in the debugger? (I2C2_OnMasterBlockSent and I2C2_OnMasterBlockReceived)?

3) if i try to use "CI2C1_SelectSlaveDevice" method for set a new slave, i get "error=0x08", "The master device is busy". Why?



later i planning to use I2S port in FRDM-K64F, but i think what I can not work with it as long as I do not understand how to properly use LDD_components in PEx.



P.S. I tried to use another code for I2C, based on a macros. and it work finely....