TMS320F28027F: TMS320F28027F

Part Number: TMS320F28027F
Other Parts Discussed in Thread: LAUNCHXL-F28027F, C2000WARE, , ENERGIA

Tool/software:

Can any one help me to work on i2c interface using bmp sensor of C2000 piccolo Launchxl-f28027f i have tried many way not getting please check 

  • Hi Kishor,

    As a starting point, you can refer to the I2C EEPROM example as a starting point for interfacing with a sensor. If you have any specific questions on the implementation, let me know and I can help.

    C:\ti\c2000\C2000Ware_5_04_00_00\device_support\f2802x\examples\structs\i2c_eeprom

    Best Regards,

    Aishwarya

  • Hi Aishwarya Rajesh

    "I've written the logic to interface the BMP280 sensor with the TMS320F28027F using I2C, but I'm not getting any output. Please take a look at the code and let me know what might be wrong."

    Fullscreen
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    #include "DSP28x_Project.h" // Device Headerfile and Examples Include File
    #include <stdio.h> // For sprintf
    #include <stdint.h> // For uint8_t, int16_t, etc.
    // BMP280 Definitions
    #define BMP280_ADDR 0x76 // BMP280 I2C address (0x76 if SDO is low, 0x77 if SDO is high)
    #define BMP280_CALIB_DATA_SIZE 24
    // BMP280 Calibration Data
    uint16_t dig_T1;
    int16_t dig_T2, dig_T3;
    uint16_t dig_P1;
    int16_t dig_P2, dig_P3, dig_P4, dig_P5, dig_P6, dig_P7, dig_P8, dig_P9;
    // Global variable for fine temperature calculation
    int32_t t_fine;
    // Function Prototypes
    void InitI2C(void);
    void BMP280_Init(void);
    void I2C_Write(uint8_t slave_addr, uint8_t reg_addr, uint8_t data);
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

  • Kishor,

    While I can't review code, let me know if you are seeing any output on the GPIOs or nothing at all? If there is no output on the pins, please take a look at the GPIO configurations and the physical connections between MCU and EEPROM. If there is output, then we can look at code configurations further. Please point me towards the specific portion of your code there may be an issue.

    Here is a thread that could be relevant: (+) TMS320F28027F: I2C sets Stop condition without being commanded to - C2000 microcontrollers forum - C2000Tm︎ microcontrollers - TI E2E support forums. There could be other E2Es as well on the forum that could be helpful.

    Best Regards,

    Aishwarya

  • Hi Aishwarya Rajesh,

     Referred the I2C EEPROM example instead of using external EEPROM i used BMP280 sensor and changed the slave address in the code. And also implemented the sci for debug prints. in that code just i implemented the i2c scanner code to found the i2c device connected by checking the loop from 0 to 128  devices. As bmp sensor, if i connected the SDO pin to ground it should get the 0x76 or if i connect to VCC it should get 0x77. it is not founding. why this actually all the initialization is done in the code.

    1.    Issues faced

    1)    Using sample BMP280 Sensor for any controller from Git.

    https://github.com/ebrezadev/BMP280-Barometric-Pressure-and-Temperature-Sensor-C-Driver/tree/main

    • From the above link download the zip file and add that four files in the program.
    • Right click on the project name and in pop window you will see the add files click on that and see the zip files where you download and extracted them, add source files to SRC and header file to INC.
    • Now need to implement the code in bmp280_low_level.c and main.c as per our MCU dependent.
    • In main function i2c initialization is done, sci implementation is done for debug print.
    • Flash the program.
    • It halt at the Read operation timeout print in read function, while debugging line by line it is Wait for data to be ready waiting for some time until timeout and prints the message Read operation timeout.
    • To overcome this first I need to check the whether i2c address is getting are not, then I implemented the i2c scanner code in main function called in while loop.
    • This scanner code is commented in main comment out the code to work on i2c scanner It while check the 128 device address.
    • BMP280 I2C device address is depend up on SDO pin if the SDO pin is connected to Ground it is 0x76 also if connected to VCC it is 0x77 also per connection it is connected to the ground.
    • The scanner function should detect the address of BMP280 sensor at 0x76.
    • But by checking this also device address is not getting.

    2)    Using logic analyzer check the I2C lines

    • To debug whether I2C lines are working or not-working.
    • Taken the I2C master code sample from git in which only contain the write function.

    https://github.com/kiranj26/C2000-Piccolo-F28027F-Projects/tree/main/examples/I2C/I2C_Master

    • Then connect the logic analyzer channels to SDA and SCL lines of Launchpad and ground to ground.
    • We found some raw data on SDA and SCL lines.
    • Then implemented the read function in this master code along with the debug prints and delay function calls it is also halted at the stop condition to complete the i2c communication completely but it is timeout without completing.

    3)    Worked on EEPROM Example

    • EEPROM Example program for external EEPROM device instead of that we are using the slave as BMP280 sensor and changed the slave address and implement the SCI message prints to debug what is getting.
    • Here also I didn’t get the output.
    • In this also program is halting in read function, read function is not working proper.

    4)    Energia IDE

    • Installed energia ide version 17.
    • Install code generator tool of version 6.2.6.
    • While installing give the path where eneria>>hardware>>tools>>c2000 and install.
    • Open ide and it is same as Arduino select board c2000-TMS320F28027F and serial port com11.
    • To check which com go to device drive>>port>>there we can see the com of our board if connect.
    • In this ide also implement the sample code of i2c scanner.

            The device is not found properly

    This is my bmp_low_level.c contains the read and write function.

    Fullscreen
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    /*BMP280 barometric pressure and temperature sensor C Driver*/
    /*Reza Ebrahimi - https://github.com/ebrezadev */
    /*Version 1.0*/
    #include "bmp280.h"
    #include "sci.h"
    #include "i2c.h"
    //#include "DSP28x_Project.h"
    /* Writes an array (data[]) of arbitrary size (dataLength) to I2C address (deviceAddress),
    starting from an internal register address (startRegisterAddress) */
    void bmp280_write_array(uint8_t deviceAddress, uint8_t startRegisterAddress, uint8_t *data, uint8_t dataLength)
    {
    uint8_t i;
    EALLOW;
    // Enable I2C0 for writing
    I2caRegs.I2CMDR.bit.IRS = 1; // Set to idle state
    I2caRegs.I2CSAR = deviceAddress; // Set I2C device address
    I2caRegs.I2CCNT = dataLength + 1; // Set number of bytes to send (register + dataLength)
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
      

    This is my main.c

    Fullscreen
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    #include "DSP28x_Project.h" // Device Headerfile and Examples Include File
    #include "clk.h"
    #include "gpio.h"
    #include "sci.h"
    #include "i2c.h"
    //// Function Prototypes
    void scia_echoback_init(void);
    void scia_fifo_init(void);
    void scia_xmit(int a);
    void scia_msg(char *msg);
    void scia_receive_string(char *buf, uint16_t max_len);
    // Globals
    CLK_Handle myClk;
    GPIO_Handle myGpio;
    SCI_Handle mySci;
    I2C_Handle i2cHandle;
    // Main
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

  • Kishor,

    Could you confirm if you are seeing any output on the scope and share what you are seeing. I am not clear on that point. Also, make sure you have a pull up resistor connecting SDA and SCL to VDDIO at around 2.2 kOhms. Refer to this App Note for some more information as well: Interfacing EEPROM Using C2000 I2C Module

    Please also give me 1-2 days to look into this further and get back to you. 

    Best Regards,

    Aishwarya

  • HI Aishwarya Rajesh,

    I'm using 4.7kOhms  pull up resistor connecting SDA and SCL to VCC .

    output iam seeing

    read operation is timeout in bmp_low_level.c.

  • Kishor,

    Can you send an image of the reading on the oscilloscope.

    Best Regards,

    Aishwarya

  • Hi Aishwarya Rajesh,

    i have checked in logic Analyzer 

  • Kishor,

    Let me look into this further and get back to you.

    Best Regards,

    Aishwarya

  • Kishor,

    Try referring to these threads and let me know if you have any further questions: 

    28027F external control through I2C - motor control

    CCS/LAUNCHXL-F28027: How to establish I2C communication between LAUNCHXL-F28027 and MCP9808?

    Best Regards,

    Aishwarya

  • Hi Aishwarya Rajesh,

    Thanks for this response i have detected bmp280 sensor chip id (i2c detected ) by this thread and now working on get bmp sensor data if any issues i will get back to you.

  • Kishor,

    Glad to hear, let me know if you have any other questions, and/or please mark this thread as resolved accordingly.

    Best Regards,

    Aishwarya