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.

Compiler/CC2541: cc2541

Part Number: CC2541
Other Parts Discussed in Thread: CC2640R2F, CC2650

Tool/software: TI C/C++ Compiler

hi, i have a project use BLE and MPU6050. now i'm reading data from MPU by CC2541. 

i'm confused that should use HAL or code directly into resigter to read data from MPU.

any idea for this case :((. i set IAR complier 30 days, and just 4 days left :((.help me

 

  • i can't read anything :(
  • i use this board hm10 cc2541
  • Hi Phan Lam,

    Why do you not use hal_i2c of TI for CC254x ?
    And I dont understand your code.
    You can start with SimpleBLEPeripheral to study with ble stack of CC2541.
    If you want a example of i2c on cc2541, you can use Sensortag example
  • Hi Phan,

    You should definitely use the HAL Driver code - see the Software Developer's Guide and the HAL Driver API @ C:\Texas Instruments\BLE-CC254x-1.4.2.2\Documents

    Also if the cost of IAR is an issue, you could get a CC2650 or CC2640R2F Launchpad and use CCS, it's free !

    Regards,
    Rebel
  • em đã thử dùng các thư viện hal.nhưng ngoài thư viện hal_led ra thì em ko dùng đc cái nào khác :(. nên đọc datasheet rồi code thanh ghi, cũng code đc timer và uart thì có vẻ thấy cái này ok hơn.nhưng I2c thì khó hơn hẳn.
    a có thể chỉ em cách dùng hal đc ko . em đã define trong processor các thứ mà ko rõ lắm. em cảm ơn
  • Hi Pham Lam,

    Now, I rarely use CC2541 because CC2650 is better. This is my old code for last year. You can download hal_i2c.h and hal_i2c.c in attached file.
    You can open SimpleBLEPeripheral example. And write a i2c test code in SimpleBLEPeripheral_init function.

    void I2CWriteData(uint8 Command,uint8 Data)
    {
      uint8 pBuf[2];
      pBuf[0] = Command;
      pBuf[1] = Data;
      HalI2CWrite(2,pBuf);
    }
    uint8 I2CReadData(uint8 Command)
    {
      uint8 pBuf[1];
      uint8 pBufR[1];
      pBufR[0] = 0x00;
      pBuf[0] = Command;
      HalI2CWrite(1,pBuf);
      HalI2CRead(1,pBufR);
    
      return(pBufR[0]) ; 
    }
    uint8 lis2hd_who()
    {
      HalI2CInit(LIS2DH_DEFAULT_ADDRESS, (i2cClock_t)i2cClock_267KHZ);
    
      if(LIS2DH_I_AM_MASK == I2CReadData(LIS2DH_WHO_AM_I))
      {
        HalI2CDisable();
        return(1);
      }
      HalI2CDisable();
      return(0);
    }

    hal_i2c.rar