Forum Discussion

Inematov's avatar
Inematov
Icon for New Contributor rankNew Contributor
6 years ago

Hi all I am using the i2C IP Core. In NIOS i would like to get data from an Bosch BME280.

Now i get (console output) always the same value, nothing changes.. Also not if i try to get data from other geisters. So i believe i do something wrong, but i don`t know what.. or where to start searching. Can anyone support me on that?

My first step is just to get something, regardless of which data exactly, compensation parameter etc..

There is communication (oscilloscope), but nothing correct.

Find in the attachment screenshot of:

  • QSYS
  • NIOS c code
  • NIOS c code

8 Replies

  • AnandRaj_S_Intel's avatar
    AnandRaj_S_Intel
    Icon for Regular Contributor rankRegular Contributor

    Hi Roman,

    Can you share the design?

    Your driver & Qsys system looks fine, Need to check the software side.

    Regards

    Anand

  • Inematov's avatar
    Inematov
    Icon for New Contributor rankNew Contributor

    Hi Anand

    Find in the attachment:

    • C-Code (main.txt)
    • Scope picture from an working communication with an Arduino

    Somehow strange... today i can`t even get any value, its always empty.

    But i get no error, just no data.

    Thanks!

    Regards

    Roman

    • Inematov's avatar
      Inematov
      Icon for New Contributor rankNew Contributor

      Hi Anand

      With the code in the attachment i get the following output:

      Hello from Nios II!

      targetadress 0x0

      Error

      Read chip ID: Read chip ID: Read chip ID: Read chip ID: Read chip ID: Data

      Data

      Data

      Data

      so it seems he even do not set the target address 0x76.

      When i use the oscilloscope, there is no communication on the pins.

      Thank you!

      Regards

      Roman

  • AnandRaj_S_Intel's avatar
    AnandRaj_S_Intel
    Icon for Regular Contributor rankRegular Contributor

    Hi Roman,

    Is your BME280 SDO pin connected to the ground? check hardware connectivity.

    Try to read the slave address without writing it.

    Regards

    Anand

  • Inematov's avatar
    Inematov
    Icon for New Contributor rankNew Contributor

    Hi Anand

    Oh i found the wiring issue... (unbelivable :( )

    However, now i`m back at my initial problem, that the slave sends me some data that i am not expecting.

    In the attachment is an oscilloscope picture, communication via NIOS2. The Slave sends me wrong data, but i a don`t know why and how i can control that from NIOS. (An osci picture from an working communication via arduino is in my first post)

    I thought it is a missing initialization step but i can`t find any difference to the examples from Bosch.

          alt_u32 txbuffer[0x200];
     
          alt_u32 rxbuffer[0x200];
          txbuffer[0] = 0xFA; //MSB
          txbuffer[1] = 0xFB; //LSB
          txbuffer[2] = 0xFC; //XLSB
     
      	while (1)
      	{
      		status = alt_avalon_i2c_master_tx_rx(i2c_dev, txbuffer, 1, rxbuffer, 3,    ALT_AVALON_I2C_NO_INTERRUPTS);
     
            usleep(1000000);
        }
  • AnandRaj_S_Intel's avatar
    AnandRaj_S_Intel
    Icon for Regular Contributor rankRegular Contributor

    Hi,

    1. Temperature data may be randomly changing better read some other register.
    2. The tx buffer contains the 1-byte address, Is address (FA)correct ???

    it should be 2 bytes FA & FB for temperature data.

    Instead of reading temp data, read chip id and check if you are getting expected output for debugging.

    Buffer[0]=D0;

    alt_avalon_i2c_master_tx_rx(i2c_ptr,buffer,1,buffer,1,0);

    Regards

    Anand