Show the result over UART with Tera Term

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Anonymous
Not applicable

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

0 Likes
1 Solution
rola_264706
Level 8
Level 8
50 likes received 25 likes received 10 likes received

You have to write to the status reg to start a conversion or wait for 64 sec for new data see pictures

   

Also this can be hard to use as if the time is not set the device just sits there and returns 0 for all data. 

   

Please send the complete code so we can check it.

   

   

View solution in original post

0 Likes
4 Replies
rola_264706
Level 8
Level 8
50 likes received 25 likes received 10 likes received

What DS3231 module are you using?

0 Likes
Anonymous
Not applicable

Hi Bob,

Thank you for the reply,
I am using the DS3231 ZS-042 
here is the datasheet : https://datasheets.maximintegrated.com/en/ds/DS3231.pdf

0 Likes
rola_264706
Level 8
Level 8
50 likes received 25 likes received 10 likes received

You have to write to the status reg to start a conversion or wait for 64 sec for new data see pictures

   

Also this can be hard to use as if the time is not set the device just sits there and returns 0 for all data. 

   

Please send the complete code so we can check it.

   

   

0 Likes
lock attach
Attachments are accessible only for community members.
Anonymous
Not applicable

Hi Bob,

Here you can find the files.
Thank you !

0 Likes