AnsweredAssumed Answered

x-nucleo-6180XA1

Question asked by AntonioB on May 4, 2016
Latest reply on Jul 11, 2016 by AntonioB
Hi to all, i have this shield x-nucleo-6180XA1 with mi STM32L152RE, i setting PB8 and PB9 for I2C1, i want to test the shild i want to see the who i am,  i write this easy code 


 #define IDENTIFICATION__MODEL_ID  0x000   //who I am
#define PROXW  0x52
#define PROXR  0x53
#define DEFUALT_ADDR 0X29


void I2C_WHOAMI(I2C_HandleTypeDef *hi2c1, __IO uint8_t whoami){
     
  while((hi2c1->Instance->SR2&BUSY)==BUSY);
  //  Start
    hi2c1->Instance->CR1 |= START;

  while((hi2c1->Instance->SR1&SB)!=SB);
  dummy16 = hi2c1->Instance->SR1;
 
  hi2c1->Instance->DR = PROXW;
  while((hi2c1->Instance->SR1&ADDR)!=ADDR);
  dummy16 = hi2c1->Instance->SR1;
  dummy16 = hi2c1->Instance->SR2;
  while((hi2c1->Instance->SR1&TXE)!=TXE);

 
 hi2c1->Instance->DR = whoami; //WHOAMI;
  while((hi2c1->Instance->SR1&(TXE|BTF))!=(TXE|BTF));
  //  Restart
  hi2c1->Instance->CR1 |= START;
  while((hi2c1->Instance->SR1&SB)!=SB);
  dummy16 = hi2c1->Instance->SR1;

  hi2c1->Instance->DR = PROXR;
  while((hi2c1->Instance->SR1&ADDR)!=ADDR);
  dummy16 = hi2c1->Instance->SR1;
  dummy16 = hi2c1->Instance->SR2;

  while((hi2c1->Instance->SR1&(RXNE))!=(RXNE));
  dummy16 = hi2c1->Instance->DR;
  if (dummy16==(uint16_t)180)    //0xB4
  {
    HAL_GPIO_WritePin(LD2_GPIO_Port,LD2_Pin,GPIO_PIN_SET);
 while((1));
  }
hi2c1->Instance->CR1 |= STOP;

}


in the main.c  i have this

  // whoami
I2C_WHOAMI(&hi2c1,IDENTIFICATION__MODEL_ID);


i don't see nothing, i use this code with other shield it's work well.
can you help me?

best regards
A.



Outcomes