1 2 Previous Next 19 Replies Latest reply on Jun 20, 2018 7:56 AM by pgrlopes_3232321

    EZI2C slave only sending a couple of values, then stops

    pgrlopes_3232321

      Hey guys.

       

      I've managed to set my ESP32 up as a master device and im trying to get a value from a sensor that is connected to my PSOC, so my psoc is my slave. When I load the code to each device, the first few iterations will indeed send the values im reading from the PSOC to the ESP, but from there on I get no values back from the request function of my master and it stops sending information.

       

      I've tried changing the ezi2c rate, tried changing the frequency at which im sending information and got nothing, it keeps happening.

       

      Was wondering if anyone can give me any help.

       

      Board - PSOC5LP-059

       

      This is my main code:

      void Initialize(void)
      {
          CyGlobalIntEnable;  // Uncomment this line to enable global interrupts.
              
          UART_1_Start();
          CyDelay(100);// waiting for clear start after power on
          UART_1_PutCRLF(' ');
          UART_1_PutString("Temperature sensor Maxim DS18B20:\r\n");
          
          DS18x8_1_Start();
          ADC_Start();
          
          //void I2C_SlaveInitReadBuf(uint8 * rdBuf, uint8 bufSize);
          //void I2C_SlaveInitWriteBuf(uint8 * wrBuf, uint8 bufSize);
          //I2C_slave_Start();
          
          EZI2C_SetBuffer1(sizeof(rdBuf), 8, rdBuf);
          EZI2C_Start();
          
          temp_interrupt_StartEx(isr_Timer);
      }
      
      int main()
      {
      
      
          Initialize();
          
          char tempFloatToArray[4];
          
          flag_Timer = 1; // force first measument instantly
          float temp_read;
          float voltage_read, current;
          uint8 i;
          
          uint8 activity;
      
      
          
          for(;;) 
          { 
              
              voltage_read = convert_current();
              current = (voltage_read-2.5)/current_sensitivity;
              
              
              
              temp_read=read_temperature(); // returns a float with the temperature
              
              memcpy(&tempFloatToArray, &temp_read, sizeof(tempFloatToArray)); //transforms the float into a char array with 4 bytes
              
              if(temp_read != -1000){ //reading of temp was correct
                  
                  activity=EZI2C_GetActivity();
                   
                  if((EZI2C_GetActivity() & EZI2C_STATUS_BUSY)==0){ //fill the buffer only when it is not being accessed
                      
                      UART_1_PutString("ENTREI NO IF**************\r\n");
                      
                      for(i=0;i<sizeof(tempFloatToArray);i++){
                      
                          rdBuf[i]=tempFloatToArray[i];
                          
                      }
                  
                  }
                  
              }  
          }
      }
      
        1 2 Previous Next