3 Replies Latest reply on Mar 28, 2017 5:24 AM by content.librarian

    Show the result over UART with Tera Term

    content.librarian

      Hi,

      I am using on my project the CY8C4247LQI-BL483 chip, and the I2C real-time clock DS3231.
      Well, The DS3231 has an integrated temperature- compensated crystal oscillator (TCXO) and I want to see the temperature using Tera Term.
      On the desig, I put an I2C Master and the UART [V2.50].
      I can read the temperature in the register using the debugger but I want to send this data to make it visual with the terminal and I don't know which function should I use.

      Here is my code : 

         

      --------------------------------------------------------------

         

      #include <project.h>
      #include <stdio.h>

         


      static uint32 SetDSAddress(uint8_t DSAddress)        
      {
      uint32 Result;    
          Result = I2C_I2CMasterSendStart(DSAddress,I2C_I2C_WRITE_XFER_MODE);
          Result = I2C_I2CMasterWriteByte((uint32)(DSAddress));
          return Result;
      }
      //*******************MS***************************************************

         

      int main(void)
      {
          //uint8 TEMPLSB = 0x12;           LSB of Temp
          uint8 TEMPMSB  = 0x11;         //MSB of Temp
          uint8 DSAdd         = 0x68;        //DS3231 Address
          uint8 Result;                              //Result
          volatile uint32 opresult;
          
          
          I2C_Start();
          CyDelay(100);
          UART_Start();
          I2C_I2CMasterClearStatus();        

         


          UART_PutString( "  Testing UART  " );   //testing the transmission
              
              while(1)
              {            

         

                  Result = I2C_I2CMasterSendStart(DSAdd,I2C_I2C_WRITE_XFER_MODE);
                  Result = I2C_I2CMasterWriteByte(TEMPMSB);
                  Result = I2C_I2CMasterSendRestart(DSAdd,I2C_I2C_READ_XFER_MODE);
                  opresult= I2C_I2CMasterReadByte(I2C_I2C_ACK_DATA);
                  UART_PutChar(I2C_I2C_ACK_DATA);
                  Result = I2C_I2CMasterSendStop();
                  CyDelay(100);
                  }
      }

         

      ----------------------------------------------------

         

      Thank you very much for your help!
      M. SABAN