- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
What DS3231 module are you using?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content