<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: DS1307 RTC interface issue with S32K144 in S32K</title>
    <link>https://community.nxp.com/t5/S32K/DS1307-RTC-interface-issue-with-S32K144/m-p/1820885#M32452</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.nxp.com/t5/user/viewprofilepage/user-id/230396"&gt;@KKB&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;According to the information provided, the communication from the S32K1 looks correct. So, I suggest you contact your device supplier to verify the required process and steps to work with the RTC.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If my understanding is wrong, please share the output signals of the S32K1 to verify the driver's behavior.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;B.R.&lt;/P&gt;
&lt;P&gt;VaneB&lt;/P&gt;</description>
    <pubDate>Mon, 04 Mar 2024 21:57:03 GMT</pubDate>
    <dc:creator>VaneB</dc:creator>
    <dc:date>2024-03-04T21:57:03Z</dc:date>
    <item>
      <title>DS1307 RTC interface issue with S32K144</title>
      <link>https://community.nxp.com/t5/S32K/DS1307-RTC-interface-issue-with-S32K144/m-p/1820336#M32410</link>
      <description>&lt;P&gt;I am having issue with interfacing the ds1307 RTC with S32K144. I will post the code, the first code is main.c and second is the driver. when i call setdate everything works fine but after thsi ebery function call goes to status busy that is I2B bus does not return to idle state:&lt;/P&gt;&lt;LI-CODE lang="c"&gt;/**********	Includes **********/
#include "sdk_project_config.h"
#include &amp;lt;stdio.h&amp;gt;
#include &amp;lt;string.h&amp;gt;
#include &amp;lt;rtc.h&amp;gt;
#include &amp;lt;uart_bms.h&amp;gt;
#include &amp;lt;ds1307_rtc.h&amp;gt;

char timeDate[] = "29-02-2024 5:39:00";
int main(void)
{
  cmd_error State = {0};

  // Clock initialization
  CLOCK_SYS_Init(g_clockManConfigsArr, CLOCK_MANAGER_CONFIG_CNT, g_clockManCallbacksArr, CLOCK_MANAGER_CALLBACK_CNT);
  CLOCK_SYS_UpdateConfiguration(0U, CLOCK_MANAGER_POLICY_AGREEMENT);
  CLOCK_DRV_Init(&amp;amp;clockMan1_InitConfig0);

  // Pin initialization
  PINS_DRV_Init(NUM_OF_CONFIGURED_PINS0, g_pin_mux_InitConfigArr0);

  // UART initialization
  UARTInit();

  // RTC initialization
  DS1307_Init();

  DS1307_SetDate(3);
  DS1307_SetMonth(4);
  DS1307_SetYear(2024);
  DS1307_SetHour(11);
  DS1307_SetMinute(22);
  DS1307_SetSecond(10);

  uint8_t date = DS1307_GetDate();
  uint8_t month = DS1307_GetMonth();
  uint16_t year = DS1307_GetYear();
  uint8_t hour = DS1307_GetHour();
  uint8_t minute = DS1307_GetMinute();
  uint8_t second = DS1307_GetSecond();

//  char dateStr[11]; // Date format DD/MM/YYYY
//  sprintf(dateStr, "%02d/%02d/%04d", date, month, year);
//  LPUART_DRV_SendDataBlocking(0,  (uint8_t*)dateStr, sizeof(dateStr), 1000);

  char timeStr[9]; // Time format HH:MM:SS
  sprintf(timeStr, "%02d:%02d:%02d", hour, minute, second);
  LPUART_DRV_SendDataBlocking(0, (uint8_t*)timeStr, sizeof(timeStr), 1000);

  while (1)
  {

	  // Receive from the UART
      UARTReceive();

      // Send the command from the UART
      SendCmd(&amp;amp;State);



      memset(buffer, 0, BUFFER_SIZE);
      bufferIdx = 0;

  }
  return 0;
}&lt;/LI-CODE&gt;&lt;LI-CODE lang="c"&gt;/*
 * ds1307_rtc.c
 *
 *  Created on: Mar 1, 2024
 *      Author: kaush
 */

#include "sdk_project_config.h"
#include &amp;lt;stdio.h&amp;gt;
#include &amp;lt;string.h&amp;gt;
#include &amp;lt;rtc.h&amp;gt;
#include &amp;lt;ds1307_rtc.h&amp;gt;
#include &amp;lt;uart_bms.h&amp;gt;


lpi2c_master_state_t ds1307Lpi2cMasterState;
lpi2c_slave_state_t ds1307Lpi2cSlaveState;

void DS1307_Init() {
    LPI2C_DRV_MasterInit(LPI2C_INSTANCE, &amp;amp;lpi2c0_MasterConfig0, &amp;amp;ds1307Lpi2cMasterState);
  //  DS1307_SetClockHalt(0);
}

void DS1307_SetClockHalt(uint8_t halt) {
    uint8_t ch = (halt ? 1 &amp;lt;&amp;lt; 7 : 0);
    uint8_t secondsReg = DS1307_GetRegByte(DS1307_REG_SECOND) &amp;amp; 0x7F;
    DS1307_SetRegByte(DS1307_REG_SECOND, ch | secondsReg);
}

uint8_t DS1307_GetClockHalt(void) {
	return (DS1307_GetRegByte(DS1307_REG_SECOND) &amp;amp; 0x80) &amp;gt;&amp;gt; 7;
}


void DS1307_SetRegByte(uint8_t regAddr, uint8_t val) {
    uint8_t bytes[2] = { regAddr, val };
    LPI2C_DRV_MasterSendDataBlocking(LPI2C_INSTANCE, bytes, 2, true, 1000);
}

uint8_t DS1307_GetRegByte(uint8_t regAddr) {
    uint8_t val = 0;
    LPI2C_DRV_MasterSendDataBlocking(LPI2C_INSTANCE, &amp;amp;regAddr, 1, true, 1000);
    LPI2C_DRV_MasterReceiveDataBlocking(LPI2C_INSTANCE, &amp;amp;val, 1, true, 1000);
    return val;
}


uint8_t DS1307_GetDayOfWeek(void) {
	return DS1307_DecodeBCD(DS1307_GetRegByte(DS1307_REG_DOW));
}


uint8_t DS1307_GetDate(void) {
	return DS1307_DecodeBCD(DS1307_GetRegByte(DS1307_REG_DATE));
}


uint8_t DS1307_GetMonth(void) {
	return DS1307_DecodeBCD(DS1307_GetRegByte(DS1307_REG_MONTH));
}


uint16_t DS1307_GetYear(void) {
	uint16_t cen = DS1307_GetRegByte(DS1307_REG_CENT) * 100;
	return DS1307_DecodeBCD(DS1307_GetRegByte(DS1307_REG_YEAR)) + cen;
}


uint8_t DS1307_GetHour(void) {
	return DS1307_DecodeBCD(DS1307_GetRegByte(DS1307_REG_HOUR) &amp;amp; 0x3f);
}


uint8_t DS1307_GetMinute(void) {
	return DS1307_DecodeBCD(DS1307_GetRegByte(DS1307_REG_MINUTE));
}


uint8_t DS1307_GetSecond(void) {
	return DS1307_DecodeBCD(DS1307_GetRegByte(DS1307_REG_SECOND) &amp;amp; 0x7f);
}


void DS1307_SetDayOfWeek(uint8_t dayOfWeek) {
	DS1307_SetRegByte(DS1307_REG_DOW, DS1307_EncodeBCD(dayOfWeek));
}


void DS1307_SetDate(uint8_t date) {
	DS1307_SetRegByte(DS1307_REG_DATE, DS1307_EncodeBCD(date));
}


void DS1307_SetMonth(uint8_t month) {
	DS1307_SetRegByte(DS1307_REG_MONTH, DS1307_EncodeBCD(month));
}


void DS1307_SetYear(uint16_t year) {
	DS1307_SetRegByte(DS1307_REG_CENT, year / 100);
	DS1307_SetRegByte(DS1307_REG_YEAR, DS1307_EncodeBCD(year % 100));
}


void DS1307_SetHour(uint8_t hour_24mode) {
	DS1307_SetRegByte(DS1307_REG_HOUR, DS1307_EncodeBCD(hour_24mode &amp;amp; 0x3f));
}


void DS1307_SetMinute(uint8_t minute) {
	DS1307_SetRegByte(DS1307_REG_MINUTE, DS1307_EncodeBCD(minute));
}


void DS1307_SetSecond(uint8_t second) {
	uint8_t ch = DS1307_GetClockHalt();
	DS1307_SetRegByte(DS1307_REG_SECOND, DS1307_EncodeBCD(second | ch));
}


uint8_t DS1307_DecodeBCD(uint8_t bin) {
	return (((bin &amp;amp; 0xf0) &amp;gt;&amp;gt; 4) * 10) + (bin &amp;amp; 0x0f);
}

uint8_t DS1307_EncodeBCD(uint8_t dec) {
	return (dec % 10 + ((dec / 10) &amp;lt;&amp;lt; 4));
}

void Display_DateTime()
{
    uint8_t date = DS1307_GetDate();
    uint8_t month = DS1307_GetMonth();
    uint16_t year = DS1307_GetYear();
    uint8_t hour = DS1307_GetHour();
    uint8_t minute = DS1307_GetMinute();
    uint8_t second = DS1307_GetSecond();

    char dateStr[11]; // Date format DD/MM/YYYY
    sprintf(dateStr, "%02d/%02d/%04d", date, month, year);
    LPUART_DRV_SendDataBlocking(0,  (uint8_t *)dateStr, sizeof(dateStr), 1000);

    char timeStr[9]; // Time format HH:MM:SS
    sprintf(timeStr, "%02d:%02d:%02d", hour, minute, second);
    LPUART_DRV_SendDataBlocking(0, (uint8_t *)timeStr, sizeof(timeStr), 1000);
}
&lt;/LI-CODE&gt;</description>
      <pubDate>Mon, 04 Mar 2024 08:37:11 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S32K/DS1307-RTC-interface-issue-with-S32K144/m-p/1820336#M32410</guid>
      <dc:creator>KKB</dc:creator>
      <dc:date>2024-03-04T08:37:11Z</dc:date>
    </item>
    <item>
      <title>Re: DS1307 RTC interface issue with S32K144</title>
      <link>https://community.nxp.com/t5/S32K/DS1307-RTC-interface-issue-with-S32K144/m-p/1820885#M32452</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.nxp.com/t5/user/viewprofilepage/user-id/230396"&gt;@KKB&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;According to the information provided, the communication from the S32K1 looks correct. So, I suggest you contact your device supplier to verify the required process and steps to work with the RTC.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If my understanding is wrong, please share the output signals of the S32K1 to verify the driver's behavior.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;B.R.&lt;/P&gt;
&lt;P&gt;VaneB&lt;/P&gt;</description>
      <pubDate>Mon, 04 Mar 2024 21:57:03 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S32K/DS1307-RTC-interface-issue-with-S32K144/m-p/1820885#M32452</guid>
      <dc:creator>VaneB</dc:creator>
      <dc:date>2024-03-04T21:57:03Z</dc:date>
    </item>
    <item>
      <title>Re: DS1307 RTC interface issue with S32K144</title>
      <link>https://community.nxp.com/t5/S32K/DS1307-RTC-interface-issue-with-S32K144/m-p/1853371#M34596</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.nxp.com/t5/user/viewprofilepage/user-id/230396"&gt;@KKB&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is it possible to share the full project? I am also trying to interface the DS1307 with S32k3 series but I am not able to come up with the output.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance.&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Sandy&lt;/P&gt;</description>
      <pubDate>Wed, 24 Apr 2024 10:28:33 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S32K/DS1307-RTC-interface-issue-with-S32K144/m-p/1853371#M34596</guid>
      <dc:creator>SandyHCL</dc:creator>
      <dc:date>2024-04-24T10:28:33Z</dc:date>
    </item>
  </channel>
</rss>

