<?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>8-bit MicrocontrollersのトピックRe: PROBLEM WITH DS1307</title>
    <link>https://community.nxp.com/t5/8-bit-Microcontrollers/PROBLEM-WITH-DS1307/m-p/136153#M4233</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;Hi guys ,here is the code&amp;nbsp;of DS1307 that I`m implementing &amp;nbsp;above:&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN class="msg_source_code"&gt;&lt;SPAN class="text_smallest"&gt;Code:&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;PRE&gt;#include &amp;lt;hidef.h&amp;gt; /* for EnableInterrupts macro */#include "derivative.h" /* include peripheral declarations */#include &amp;lt;MC68HC908GP32.h&amp;gt;//#include &amp;lt;lcd.h&amp;gt;#include &amp;lt;stdio.h&amp;gt;//#include &amp;lt;lcd.c&amp;gt;#define SDA  PTC_PTC6#define SCL  PTC_PTC5#define DIR_SDA  DDRC_DDRC6#define DIR_SCL  DDRC_DDRC5#define SPEED  4               #define HOLD   1#define SLAVE_ADDRESS   0xD0   #define LEN             58     byte temp, dummy, RD_data, WR_data, ACK_flag, w, i;byte own_sl_addr = 0xD0;  byte RAM_Data[LEN];byte RTC_reg[7] @0x60;    byte Cntr_reg   @0x67;typedef struct{  byte Sec;  byte Min;  byte Hrs;  byte Day;  byte Date;  byte Month;  byte Year;}sRTC;volatile sRTC RTC @0x60;    #define Seconds         RTC.Sec#define Minutes         RTC.Min#define Hours           RTC.Hrs#define Day             RTC.Day#define Date            RTC.Date#define Month           RTC.Month#define Year            RTC.Year#define RTC_REG_START   0x00#define NV_RAM_START    0x08  /* Function definition *///void Init_CPU(void);void Init_Time_Default(void);byte GetByte(void);void WriteIICbus(byte data);void Write_Control_reg(byte ctrl);void Read_ACK(void);void Write_ACK(void);void StartBit(void);void StopBit(void);void Wait_time(byte time);void Wait_sh(byte time);void InitPLL(void);extern void LCDdelay(void);extern void Ctrl8bits(unsigned char codigo);extern void Ctrl4bits(unsigned char codigo);extern void Datos4bits(unsigned char dato);extern void Config_LCD_4bits(void);extern void printf_LCD_4bits(unsigned char fila, unsigned char columna, char *texto,char value);  void InitPLL(void){  CONFIG1 = 0x01;  CONFIG2 = 0x00;  PCTL_BCS = 0;               PCTL_PLLON = 0;      /* Disable the PLL */ /* PCTL: PLLIE=0,PLLF=0,PLLON=0,BCS=0,PRE1=0,PRE0=0,VPR1=1,VPR0=0 */ PCTL = 0x02;              /* VCO Power-of-Two multiplier E=2 */ /* PMS: MUL11=0,MUL10=0,MUL9=1,MUL8=1,MUL7=1,MUL6=1,MUL5=0,MUL4=1,MUL3=0,MUL2=0,MUL1=0,MUL0=1 */ PMS = 0x03D1;           /* Feedback divider N=977 */ /* PMRS: VRS7=1,VRS6=1,VRS5=0,VRS4=1,VRS3=0,VRS2=0,VRS1=0,VRS0=0 */ PMRS = 0xD1;             /* VCO Linear multiplier L=208 */ /* PMDS: RDS3=0,RDS2=0,RDS1=0,RDS0=1 */ PMDS = 0x01;             /* Reference clock devider R=1 */ /* PBWC: AUTO=1,LOCK=0,ACQ=0,—–=0,˜™=0,??=0,??=0,??=0 */ PBWC = 0x80;             /* Select the operating modes */   /* PCTL: PLLON=1 */ PCTL_PLLON = 1;          /* Enable the PLL */ while(!PBWC_LOCK) {                  /* Wait */ } /* PCTL: BCS=1 */ PCTL_BCS = 1;            /* Select clock source from PLL */ __asm("nop"); __asm("nop"); }void Init_Time_Default(void)  // see datasheet of DS1338;{ Seconds = 0; Minutes = 0x10; Hours = 0x12; Day = 4;      // day of week; Date = 0x11; Month = 5; Year = 6;}//********************************************************************void Write_Control_reg(byte ctrl)  // writes Cntr_reg to RTC;{ ACK_flag = 0; StartBit(); WriteIICbus(SLAVE_ADDRESS); asm nop; Read_ACK(); asm nop; if(ACK_flag !=0) {   StopBit();   return; } WriteIICbus(7);  // write address of the Control register; Read_ACK(); if(ACK_flag !=0) {   StopBit();   return; } WriteIICbus(ctrl);  // write value into Control register; Read_ACK(); if(ACK_flag !=0) {   StopBit();   return; } StopBit();}//********************************************************************void Read_Control_reg(void)   // reads Cntr_reg from RTC;{ ACK_flag = 0; StartBit(); WriteIICbus(SLAVE_ADDRESS); // RW bit = 0; asm nop; Read_ACK(); asm nop; if(ACK_flag !=0) {   StopBit();   return; } WriteIICbus(7);  // write address of the Control register; Read_ACK(); if(ACK_flag !=0) {   StopBit();   return; } StartBit(); WriteIICbus(SLAVE_ADDRESS | 1); // RW bit = 1; Read_ACK(); if(ACK_flag !=0) {   StopBit();   return; } DIR_SDA = 0; Cntr_reg = GetByte();  // read value from the Control register and save it; StopBit();}//********************************************************************void WriteRTC(void){ ACK_flag = 0; StartBit(); WriteIICbus(SLAVE_ADDRESS); asm nop; Read_ACK(); asm nop; if(ACK_flag !=0) {   StopBit();   return; } WriteIICbus(0);  // Starts write from address "0" in RTC (Seconds); Read_ACK(); if(ACK_flag !=0) {   StopBit();   return; } for(i=0;i&amp;lt;7;i++) {   WriteIICbus(RTC_reg[i]);   Read_ACK();   if(ACK_flag !=0)   {     StopBit();     return;   } } StopBit();}//********************************************************************byte ReadRTCbyte(byte addr){ ACK_flag = 0; StartBit(); WriteIICbus(SLAVE_ADDRESS); // RW bit = 0; asm nop; Read_ACK(); asm nop; if(ACK_flag !=0) {   StopBit();   return 0; } WriteIICbus(addr); Read_ACK(); if(ACK_flag !=0) {   StopBit();   return 0; } StartBit(); WriteIICbus(SLAVE_ADDRESS | 1); // RW bit = 1; Read_ACK(); if(ACK_flag !=0) {   StopBit();   return 0; } DIR_SDA = 0; RD_data = GetByte(); StopBit(); return RD_data;}//********************************************************************byte GetByte(void){ byte tempb, i;  tempb = 0; for(i=0;i&amp;lt;8;i++) {   tempb = tempb &amp;lt;&amp;lt; 1;   SCL = 1;   Wait_sh(SPEED);   tempb = tempb | SDA;   SCL = 0;   Wait_sh(SPEED - HOLD); } return tempb;}//********************************************************************void WriteIICbus(byte data){ byte tempb, i;  tempb = data; for(i=0;i&amp;lt;8;i++) {   SDA = ((tempb &amp;amp; 0x80)&amp;gt;&amp;gt;7);   tempb = tempb &amp;lt;&amp;lt; 1;   Wait_sh(HOLD);   SCL = 1;   Wait_sh(SPEED);   SCL = 0;   Wait_sh(SPEED - HOLD); }}//********************************************************************void Read_ACK(void){ DIR_SDA = 0; Wait_sh(HOLD); SCL = 1; Wait_sh(SPEED); ACK_flag = SDA; SCL = 0; DIR_SDA = 1;}//********************************************************************void Write_ACK(void){ DIR_SDA = 1; SDA = 0; Wait_sh(HOLD); SCL = 1; Wait_sh(SPEED); SCL = 0; Wait_sh(HOLD);}//********************************************************************void StartBit(void){ SDA = 1; SCL = 1; DIR_SDA = 1; DIR_SCL = 1; Wait_sh(SPEED); Wait_sh(SPEED); SDA = 0; Wait_sh(SPEED); SCL = 0; Wait_sh(SPEED);}//********************************************************************void StopBit(void){ Wait_sh(HOLD); SCL = 1; Wait_sh(SPEED); SDA = 1;}//***************************************************************************void Wait_time(byte time){  const word k = 250;  word i, temp_t = (time*k);  for (i=0;i&amp;lt;temp_t;i++)     {     asm nop;     }}//********************************************************************void Wait_sh(byte time){  word i, temp_t = time;  for (i=0;i&amp;lt;temp_t;i++)     {     asm nop;     }}void main (void)   {  DDRA_DDRA4=1 ;  DDRB_DDRB4=1 ; DDRB_DDRB5=1 ; DDRB_DDRB6=1 ; DDRB_DDRB7=1 ;  DDRC_DDRC0=1 ;  DDRC_DDRC3=1 ; DDRC_DDRC4=1 ;  EnableInterrupts; /* enable interrupts */  InitPLL(); Config_LCD_4bits();   Write_Control_reg(3);  // squarewave output 32.768kHz at RTC SQW pin; Init_Time_Default(); WriteRTC(); for(;;) {   __RESET_WATCHDOG(); /* feeds the dog */      Hours   = ReadRTCbyte(2);   Minutes = ReadRTCbyte(1);   Seconds = ReadRTCbyte(0);             Datos4bits (0x01);   printf_LCD_4bits (1,1,"h",Hours);                           printf_LCD_4bits (1,6,"m",Minutes);   printf_LCD_4bits (1,12,"s",Seconds);   //PTA = RD_data;             // Show RTC info on LEDs;   //PTB = RD_data;             // Show RTC info on LEDs;      //wait_time(250);   //asm nop;    } /* loop forever */ /* please make sure that you never leave this function */}  &lt;/PRE&gt;&lt;BR /&gt;&amp;nbsp;&lt;BR /&gt;&lt;FONT size="1"&gt;(Alban put code in SRC for lisibility)&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;BR /&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;P&gt;Message Edited by Alban on &lt;SPAN class="date_text"&gt;05-16-2006&lt;/SPAN&gt; &lt;SPAN class="time_text"&gt;01:32 PM&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 16 May 2006 02:01:35 GMT</pubDate>
    <dc:creator>ganimides</dc:creator>
    <dc:date>2006-05-16T02:01:35Z</dc:date>
    <item>
      <title>PROBLEM WITH DS1307</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/PROBLEM-WITH-DS1307/m-p/136152#M4232</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;Hi guys!&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;I have&amp;nbsp;several problems with DS1307 programming.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;First, it would seem that the information appearing on my LCD screen does not match with the information programmed within the code.&lt;BR /&gt;&lt;/DIV&gt;&lt;DIV&gt;I put by default the following:&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;Seconds = 0;&lt;BR /&gt;&amp;nbsp;Minutes = 0x10;&lt;BR /&gt;&amp;nbsp;Hours = 0x12;&lt;BR /&gt;&amp;nbsp;Day = 4;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // day of week;&lt;BR /&gt;&amp;nbsp;Date = 0x11;&lt;BR /&gt;&amp;nbsp;Month = 5;&lt;BR /&gt;&amp;nbsp;Year = 6;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;When it starts up On the LCD appears like this:&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;H: 18 m: 16: s:00 -------&amp;gt;.I think this not OK.&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;BR /&gt;Second ,the seconds remain updating but do not stop when it reachs up to 59 seconds.It remains counting to 80 seconds and minutes do not increment.---&amp;gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;why is it?&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Third, how should be the hardware configured for proper working?.I pulled up the SDA pin at PORT C of 68HC908GP32.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;If someone needs the code&amp;nbsp;that I`m talking about to be able tocheck it out,please tell me.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Thank you so much!.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Ganimides.&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 16 May 2006 01:56:10 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/PROBLEM-WITH-DS1307/m-p/136152#M4232</guid>
      <dc:creator>ganimides</dc:creator>
      <dc:date>2006-05-16T01:56:10Z</dc:date>
    </item>
    <item>
      <title>Re: PROBLEM WITH DS1307</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/PROBLEM-WITH-DS1307/m-p/136153#M4233</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;Hi guys ,here is the code&amp;nbsp;of DS1307 that I`m implementing &amp;nbsp;above:&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN class="msg_source_code"&gt;&lt;SPAN class="text_smallest"&gt;Code:&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;PRE&gt;#include &amp;lt;hidef.h&amp;gt; /* for EnableInterrupts macro */#include "derivative.h" /* include peripheral declarations */#include &amp;lt;MC68HC908GP32.h&amp;gt;//#include &amp;lt;lcd.h&amp;gt;#include &amp;lt;stdio.h&amp;gt;//#include &amp;lt;lcd.c&amp;gt;#define SDA  PTC_PTC6#define SCL  PTC_PTC5#define DIR_SDA  DDRC_DDRC6#define DIR_SCL  DDRC_DDRC5#define SPEED  4               #define HOLD   1#define SLAVE_ADDRESS   0xD0   #define LEN             58     byte temp, dummy, RD_data, WR_data, ACK_flag, w, i;byte own_sl_addr = 0xD0;  byte RAM_Data[LEN];byte RTC_reg[7] @0x60;    byte Cntr_reg   @0x67;typedef struct{  byte Sec;  byte Min;  byte Hrs;  byte Day;  byte Date;  byte Month;  byte Year;}sRTC;volatile sRTC RTC @0x60;    #define Seconds         RTC.Sec#define Minutes         RTC.Min#define Hours           RTC.Hrs#define Day             RTC.Day#define Date            RTC.Date#define Month           RTC.Month#define Year            RTC.Year#define RTC_REG_START   0x00#define NV_RAM_START    0x08  /* Function definition *///void Init_CPU(void);void Init_Time_Default(void);byte GetByte(void);void WriteIICbus(byte data);void Write_Control_reg(byte ctrl);void Read_ACK(void);void Write_ACK(void);void StartBit(void);void StopBit(void);void Wait_time(byte time);void Wait_sh(byte time);void InitPLL(void);extern void LCDdelay(void);extern void Ctrl8bits(unsigned char codigo);extern void Ctrl4bits(unsigned char codigo);extern void Datos4bits(unsigned char dato);extern void Config_LCD_4bits(void);extern void printf_LCD_4bits(unsigned char fila, unsigned char columna, char *texto,char value);  void InitPLL(void){  CONFIG1 = 0x01;  CONFIG2 = 0x00;  PCTL_BCS = 0;               PCTL_PLLON = 0;      /* Disable the PLL */ /* PCTL: PLLIE=0,PLLF=0,PLLON=0,BCS=0,PRE1=0,PRE0=0,VPR1=1,VPR0=0 */ PCTL = 0x02;              /* VCO Power-of-Two multiplier E=2 */ /* PMS: MUL11=0,MUL10=0,MUL9=1,MUL8=1,MUL7=1,MUL6=1,MUL5=0,MUL4=1,MUL3=0,MUL2=0,MUL1=0,MUL0=1 */ PMS = 0x03D1;           /* Feedback divider N=977 */ /* PMRS: VRS7=1,VRS6=1,VRS5=0,VRS4=1,VRS3=0,VRS2=0,VRS1=0,VRS0=0 */ PMRS = 0xD1;             /* VCO Linear multiplier L=208 */ /* PMDS: RDS3=0,RDS2=0,RDS1=0,RDS0=1 */ PMDS = 0x01;             /* Reference clock devider R=1 */ /* PBWC: AUTO=1,LOCK=0,ACQ=0,—–=0,˜™=0,??=0,??=0,??=0 */ PBWC = 0x80;             /* Select the operating modes */   /* PCTL: PLLON=1 */ PCTL_PLLON = 1;          /* Enable the PLL */ while(!PBWC_LOCK) {                  /* Wait */ } /* PCTL: BCS=1 */ PCTL_BCS = 1;            /* Select clock source from PLL */ __asm("nop"); __asm("nop"); }void Init_Time_Default(void)  // see datasheet of DS1338;{ Seconds = 0; Minutes = 0x10; Hours = 0x12; Day = 4;      // day of week; Date = 0x11; Month = 5; Year = 6;}//********************************************************************void Write_Control_reg(byte ctrl)  // writes Cntr_reg to RTC;{ ACK_flag = 0; StartBit(); WriteIICbus(SLAVE_ADDRESS); asm nop; Read_ACK(); asm nop; if(ACK_flag !=0) {   StopBit();   return; } WriteIICbus(7);  // write address of the Control register; Read_ACK(); if(ACK_flag !=0) {   StopBit();   return; } WriteIICbus(ctrl);  // write value into Control register; Read_ACK(); if(ACK_flag !=0) {   StopBit();   return; } StopBit();}//********************************************************************void Read_Control_reg(void)   // reads Cntr_reg from RTC;{ ACK_flag = 0; StartBit(); WriteIICbus(SLAVE_ADDRESS); // RW bit = 0; asm nop; Read_ACK(); asm nop; if(ACK_flag !=0) {   StopBit();   return; } WriteIICbus(7);  // write address of the Control register; Read_ACK(); if(ACK_flag !=0) {   StopBit();   return; } StartBit(); WriteIICbus(SLAVE_ADDRESS | 1); // RW bit = 1; Read_ACK(); if(ACK_flag !=0) {   StopBit();   return; } DIR_SDA = 0; Cntr_reg = GetByte();  // read value from the Control register and save it; StopBit();}//********************************************************************void WriteRTC(void){ ACK_flag = 0; StartBit(); WriteIICbus(SLAVE_ADDRESS); asm nop; Read_ACK(); asm nop; if(ACK_flag !=0) {   StopBit();   return; } WriteIICbus(0);  // Starts write from address "0" in RTC (Seconds); Read_ACK(); if(ACK_flag !=0) {   StopBit();   return; } for(i=0;i&amp;lt;7;i++) {   WriteIICbus(RTC_reg[i]);   Read_ACK();   if(ACK_flag !=0)   {     StopBit();     return;   } } StopBit();}//********************************************************************byte ReadRTCbyte(byte addr){ ACK_flag = 0; StartBit(); WriteIICbus(SLAVE_ADDRESS); // RW bit = 0; asm nop; Read_ACK(); asm nop; if(ACK_flag !=0) {   StopBit();   return 0; } WriteIICbus(addr); Read_ACK(); if(ACK_flag !=0) {   StopBit();   return 0; } StartBit(); WriteIICbus(SLAVE_ADDRESS | 1); // RW bit = 1; Read_ACK(); if(ACK_flag !=0) {   StopBit();   return 0; } DIR_SDA = 0; RD_data = GetByte(); StopBit(); return RD_data;}//********************************************************************byte GetByte(void){ byte tempb, i;  tempb = 0; for(i=0;i&amp;lt;8;i++) {   tempb = tempb &amp;lt;&amp;lt; 1;   SCL = 1;   Wait_sh(SPEED);   tempb = tempb | SDA;   SCL = 0;   Wait_sh(SPEED - HOLD); } return tempb;}//********************************************************************void WriteIICbus(byte data){ byte tempb, i;  tempb = data; for(i=0;i&amp;lt;8;i++) {   SDA = ((tempb &amp;amp; 0x80)&amp;gt;&amp;gt;7);   tempb = tempb &amp;lt;&amp;lt; 1;   Wait_sh(HOLD);   SCL = 1;   Wait_sh(SPEED);   SCL = 0;   Wait_sh(SPEED - HOLD); }}//********************************************************************void Read_ACK(void){ DIR_SDA = 0; Wait_sh(HOLD); SCL = 1; Wait_sh(SPEED); ACK_flag = SDA; SCL = 0; DIR_SDA = 1;}//********************************************************************void Write_ACK(void){ DIR_SDA = 1; SDA = 0; Wait_sh(HOLD); SCL = 1; Wait_sh(SPEED); SCL = 0; Wait_sh(HOLD);}//********************************************************************void StartBit(void){ SDA = 1; SCL = 1; DIR_SDA = 1; DIR_SCL = 1; Wait_sh(SPEED); Wait_sh(SPEED); SDA = 0; Wait_sh(SPEED); SCL = 0; Wait_sh(SPEED);}//********************************************************************void StopBit(void){ Wait_sh(HOLD); SCL = 1; Wait_sh(SPEED); SDA = 1;}//***************************************************************************void Wait_time(byte time){  const word k = 250;  word i, temp_t = (time*k);  for (i=0;i&amp;lt;temp_t;i++)     {     asm nop;     }}//********************************************************************void Wait_sh(byte time){  word i, temp_t = time;  for (i=0;i&amp;lt;temp_t;i++)     {     asm nop;     }}void main (void)   {  DDRA_DDRA4=1 ;  DDRB_DDRB4=1 ; DDRB_DDRB5=1 ; DDRB_DDRB6=1 ; DDRB_DDRB7=1 ;  DDRC_DDRC0=1 ;  DDRC_DDRC3=1 ; DDRC_DDRC4=1 ;  EnableInterrupts; /* enable interrupts */  InitPLL(); Config_LCD_4bits();   Write_Control_reg(3);  // squarewave output 32.768kHz at RTC SQW pin; Init_Time_Default(); WriteRTC(); for(;;) {   __RESET_WATCHDOG(); /* feeds the dog */      Hours   = ReadRTCbyte(2);   Minutes = ReadRTCbyte(1);   Seconds = ReadRTCbyte(0);             Datos4bits (0x01);   printf_LCD_4bits (1,1,"h",Hours);                           printf_LCD_4bits (1,6,"m",Minutes);   printf_LCD_4bits (1,12,"s",Seconds);   //PTA = RD_data;             // Show RTC info on LEDs;   //PTB = RD_data;             // Show RTC info on LEDs;      //wait_time(250);   //asm nop;    } /* loop forever */ /* please make sure that you never leave this function */}  &lt;/PRE&gt;&lt;BR /&gt;&amp;nbsp;&lt;BR /&gt;&lt;FONT size="1"&gt;(Alban put code in SRC for lisibility)&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;BR /&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;P&gt;Message Edited by Alban on &lt;SPAN class="date_text"&gt;05-16-2006&lt;/SPAN&gt; &lt;SPAN class="time_text"&gt;01:32 PM&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 16 May 2006 02:01:35 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/PROBLEM-WITH-DS1307/m-p/136153#M4233</guid>
      <dc:creator>ganimides</dc:creator>
      <dc:date>2006-05-16T02:01:35Z</dc:date>
    </item>
    <item>
      <title>Re: PROBLEM WITH DS1307</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/PROBLEM-WITH-DS1307/m-p/136154#M4234</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;P&gt;Hi Ganimides,&lt;/P&gt;&lt;P&gt;I don't see the problem. Your H, M, S variables are initialised in HEX, and displayed in decimal.&lt;/P&gt;&lt;P&gt;Minutes = 0x10; //converts to 16 decimal&lt;/P&gt;&lt;P&gt;Hours = 0x12; //converts to 18 decimal&lt;/P&gt;&lt;P&gt;I did not check your code but I imagine that the software has a data-type issue which is stopping the seconds wrapping round and minutes updating.&lt;/P&gt;&lt;P&gt;Mark&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 16 May 2006 17:45:48 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/PROBLEM-WITH-DS1307/m-p/136154#M4234</guid>
      <dc:creator>UK_CF_FAE</dc:creator>
      <dc:date>2006-05-16T17:45:48Z</dc:date>
    </item>
    <item>
      <title>Re: PROBLEM WITH DS1307</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/PROBLEM-WITH-DS1307/m-p/136155#M4235</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;Just want to add to what UKCFFAE said... the clock registers keep time in binary coded decimal (BCD) and you seem to be displaying the time registers as straight binary.&lt;BR /&gt;&lt;BR /&gt;Also, it seems like your hardware must be set up correctly or you probably wouldn't be seeing anything at all from the clock registers.&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 16 May 2006 18:43:56 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/PROBLEM-WITH-DS1307/m-p/136155#M4235</guid>
      <dc:creator>Wings</dc:creator>
      <dc:date>2006-05-16T18:43:56Z</dc:date>
    </item>
    <item>
      <title>Re: PROBLEM WITH DS1307</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/PROBLEM-WITH-DS1307/m-p/136156#M4236</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;P&gt;Hi guys!.&lt;/P&gt;&lt;P&gt;Thank you for taking time to see my code!.&lt;/P&gt;&lt;P&gt;Yes you are right,yesterday night I looked around much better my code&amp;nbsp;I realized that I`m displaying my data in BCD format because of the jumps that it has.&lt;/P&gt;&lt;P&gt;The problem is that I just need to make some routine to convert BCD to binary data so that I can send it out&amp;nbsp;to LCD display.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Greetings!&lt;/P&gt;&lt;P&gt;Ganimides.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 16 May 2006 19:28:37 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/PROBLEM-WITH-DS1307/m-p/136156#M4236</guid>
      <dc:creator>ganimides</dc:creator>
      <dc:date>2006-05-16T19:28:37Z</dc:date>
    </item>
    <item>
      <title>Re: PROBLEM WITH DS1307</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/PROBLEM-WITH-DS1307/m-p/136157#M4237</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;P&gt;&lt;FONT size="2"&gt;Hello Ganimides,&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;It may be simpler to convert each BCD digit to its ASCII value, and place the characters at the appropriate positions within a string (array).&amp;nbsp; The string could then be directly sent to the LCD.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;unsigned char upper_chr (unsigned char value)&lt;BR /&gt;{&lt;BR /&gt;&amp;nbsp;&amp;nbsp;return ((value &amp;gt;&amp;gt; 4) + 0x30);&lt;BR /&gt;}&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;unsigned char lower_chr (unsigned char value)&lt;BR /&gt;{&lt;BR /&gt;&amp;nbsp;&amp;nbsp;return ((value &amp;amp; 0x0F) + 0x30);&lt;BR /&gt;}&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;Regards,&lt;BR /&gt;Mac&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 17 May 2006 01:28:54 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/PROBLEM-WITH-DS1307/m-p/136157#M4237</guid>
      <dc:creator>bigmac</dc:creator>
      <dc:date>2006-05-17T01:28:54Z</dc:date>
    </item>
    <item>
      <title>Re: PROBLEM WITH DS1307</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/PROBLEM-WITH-DS1307/m-p/136158#M4238</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;Hi Bigmac!.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;I`m a little confused&amp;nbsp; with the method you described to me because I have some routine inside my LCD printig function doing something like you are mentioning.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;I show you here the 2 functions that I`m using for as follows:&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;void printf_LCD_4bits(unsigned char fila, unsigned char columna, char *texto,char value)&lt;BR /&gt;{&lt;BR /&gt;&amp;nbsp;unsigned char adrs;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;adrs = columna - 1;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;if(fila == 2)&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;adrs = adrs | 0x40;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;Ctrl4bits(adrs | 0x80);&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;while(*texto)&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&lt;BR /&gt;&amp;nbsp;Datos4bits(*texto++);&lt;BR /&gt;&amp;nbsp;Datos4bits(':');&lt;BR /&gt;&amp;nbsp;Datos4bits( ((value%1000)/100)+0x30);&amp;nbsp;&amp;lt;---look at this....&lt;BR /&gt;&amp;nbsp;Datos4bits( ((value%100)/10)+0x30);&lt;BR /&gt;&amp;nbsp;Datos4bits( (value%10)+0x30);&lt;/DIV&gt;&lt;DIV&gt;&lt;BR /&gt;}&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;void main (void)&lt;BR /&gt;&amp;nbsp;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;{&lt;BR /&gt;&amp;nbsp;&lt;BR /&gt;&amp;nbsp;DDRA_DDRA4=1 ;&lt;BR /&gt;&amp;nbsp;&lt;BR /&gt;&amp;nbsp;DDRB_DDRB4=1 ;&lt;BR /&gt;&amp;nbsp;DDRB_DDRB5=1 ;&lt;BR /&gt;&amp;nbsp;DDRB_DDRB6=1 ;&lt;BR /&gt;&amp;nbsp;DDRB_DDRB7=1 ;&lt;BR /&gt;&amp;nbsp;&lt;BR /&gt;&amp;nbsp;DDRC_DDRC0=1 ;&lt;BR /&gt;&amp;nbsp;&lt;BR /&gt;&amp;nbsp;DDRC_DDRC3=1 ;&lt;BR /&gt;&amp;nbsp;DDRC_DDRC4=1 ;&lt;BR /&gt;&amp;nbsp;&lt;BR /&gt;&amp;nbsp;&lt;BR /&gt;//EnableInterrupts; /* enable interrupts */&lt;BR /&gt;&amp;nbsp;&lt;BR /&gt;&amp;nbsp;InitPLL();&lt;BR /&gt;&amp;nbsp;&lt;BR /&gt;&amp;nbsp;Config_LCD_4bits();&lt;BR /&gt;&amp;nbsp;&lt;BR /&gt;&amp;nbsp;&lt;BR /&gt;&amp;nbsp;Write_Control_reg(3);&amp;nbsp; // squarewave output 32.768kHz at RTC SQW pin;&lt;BR /&gt;&amp;nbsp;Init_Time_Default();&lt;BR /&gt;&amp;nbsp;WriteRTC();&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;for(;&lt;IMG alt=":smileywink:" class="emoticon emoticon-smileywink" id="smileywink" src="http://freescale.i.lithium.com/i/smilies/16x16_smiley-wink.gif" title="Smiley Wink" /&gt;&lt;BR /&gt;&amp;nbsp;{&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;__RESET_WATCHDOG(); /* feeds the dog */&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;Hours&amp;nbsp;&amp;nbsp; = (ReadRTCbyte(2)+(0x30));&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;Minutes = (ReadRTCbyte(1)+(0x30));&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;Seconds = (ReadRTCbyte(0)+(0x30));&amp;nbsp;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;printf_LCD_4bits (1,1,"h",Hours);&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;printf_LCD_4bits (1,6,"m",Minutes);&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;printf_LCD_4bits (1,12,"s",Seconds);&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;//PTA = RD_data;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Show RTC info on LEDs;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;//PTB = RD_data;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Show RTC info on LEDs;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;//wait_time(250);&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;//asm nop;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;BR /&gt;&amp;nbsp;} /* loop forever */&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;BR /&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;You suggested this:&lt;/DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;void upper_char (char value);&lt;/DIV&gt;&lt;DIV&gt;{&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;return (value &amp;lt;&amp;lt; 4 + 0x30);&lt;/DIV&gt;&lt;DIV&gt;}&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;DIV&gt;void lower_char (char value);&lt;/DIV&gt;&lt;DIV&gt;{&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;return (value &lt;FONT face="Symbol"&gt;|&lt;/FONT&gt;&amp;nbsp;0F + 0x30);&lt;/DIV&gt;&lt;DIV&gt;}&lt;/DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;DIV&gt;The questions would be.....where sould I set the code you mentioned to process the incoming&amp;nbsp;BCD chars?.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Thank you very very much Big!!!&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Ganimides&lt;/DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;P&gt;Message Edited by ganimides on &lt;SPAN class="date_text"&gt;05-17-2006&lt;/SPAN&gt;&lt;SPAN class="time_text"&gt;08:57 AM&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 17 May 2006 20:53:57 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/PROBLEM-WITH-DS1307/m-p/136158#M4238</guid>
      <dc:creator>ganimides</dc:creator>
      <dc:date>2006-05-17T20:53:57Z</dc:date>
    </item>
    <item>
      <title>Re: PROBLEM WITH DS1307</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/PROBLEM-WITH-DS1307/m-p/136159#M4239</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;P&gt;When I did my 1307 routines, I did the 'bit-test' stuff I needed to do 'up front'&lt;/P&gt;&lt;P&gt;and masked that off the data.&amp;nbsp; Then took the 'number' portion of the data and&lt;/P&gt;&lt;P&gt;dropped that into my BCD_to_BIN routine.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When I had to set the data, I did it very similar.&amp;nbsp; Did the BIN_to_BCD on the&lt;/P&gt;&lt;P&gt;data, then 'or' in the other bits and write it back.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It's not rocket science, but if you don't modularize what you're doing with&lt;/P&gt;&lt;P&gt;specific 'in and out' routines, you can get messed real quick.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 17 May 2006 22:58:27 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/PROBLEM-WITH-DS1307/m-p/136159#M4239</guid>
      <dc:creator>mke_et</dc:creator>
      <dc:date>2006-05-17T22:58:27Z</dc:date>
    </item>
    <item>
      <title>Re: PROBLEM WITH DS1307</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/PROBLEM-WITH-DS1307/m-p/136160#M4240</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;P&gt;&lt;FONT size="2"&gt;Hello Ganimides,&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;Since the DS1307 registers are already in BCD format, it is simpler to do BCD to ASCII conversion, rather than BCD to binary conversion, followed by binary to ASCII conversion.&amp;nbsp; The following sequence within your code actually provides the binary to ASCII conversion, and would not be required with my proposal.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;Datos4bits(((value%1000)/100)+0x30);&lt;BR /&gt;Datos4bits(((value%100)/10)+0x30);&lt;BR /&gt;Datos4bits((value%10)+0x30);&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;The DS1307 actually uses packed BCD format, with two digits represented by a single byte.&amp;nbsp; The purpose of the &lt;FONT face="Courier New"&gt;upper_chr()&lt;/FONT&gt; &lt;FONT face="Arial"&gt;and&lt;/FONT&gt; &lt;FONT face="Courier New"&gt;lower_chr()&lt;/FONT&gt; &lt;FONT face="Arial"&gt;functions is to unpack each BCD digit, and convert to an ASCII byte.&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;The suggested new and modified functions follow.&amp;nbsp; The &lt;FONT face="Courier New"&gt;printf_LCD_4bits()&lt;/FONT&gt; &lt;FONT face="Arial"&gt;function would now only need to output a text string.&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;unsigned char&amp;nbsp;upper_char (unsigned char value);&lt;BR /&gt;{&lt;BR /&gt;&amp;nbsp;&amp;nbsp;return ((value&amp;nbsp;&amp;gt;&amp;gt; 4) + 0x30);&lt;BR /&gt;}&lt;BR /&gt;&amp;nbsp;&lt;BR /&gt;unsigned char lower_char (unsigned char value);&lt;BR /&gt;{&lt;BR /&gt;&amp;nbsp;&amp;nbsp;return ((value&amp;nbsp;&amp;amp; 0x0F) + 0x30);&lt;BR /&gt;}&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;void printf_LCD_4bits(unsigned char fila, unsigned char columna, char *texto)&lt;BR /&gt;{&lt;BR /&gt;&amp;nbsp;&amp;nbsp;unsigned char adrs;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;adrs = columna - 1;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;if(fila == 2)&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;adrs = adrs | 0x40;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;Ctrl4bits(adrs | 0x80);&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;&amp;nbsp;&amp;nbsp;while(*texto)&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Datos4bits(*texto++);&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Arial"&gt;The following code could then be included within&lt;/FONT&gt; main(), &lt;FONT face="Arial"&gt;or within another function.&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Arial"&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Arial"&gt;&lt;FONT face="Courier New"&gt;unsigned char&amp;nbsp;LCDtext[] = "xxh:xxm:xxs";&lt;BR /&gt;unsigned char Hours, Minutes, Seconds;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Arial"&gt;&lt;FONT face="Courier New"&gt;Hours&amp;nbsp;&amp;nbsp; = ReadRTCbyte(2) &amp;amp; 0x3F; // 24hr format assumed&lt;BR /&gt;Minutes = ReadRTCbyte(1) &amp;amp; 0x7F; // Mask 7 bits only&lt;BR /&gt;Seconds = ReadRTCbyte(0) &amp;amp; 0x7F;&amp;nbsp;// Mask 7 bits only&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;BR /&gt;LCDtext[0] = upper_chr (Hours);&lt;BR /&gt;LCDtext[1] = lower_chr (Hours);&lt;BR /&gt;LCDtext[4] = upper_chr (Minutes);&lt;BR /&gt;LCDtext[5] = lower_chr (Minutes);&lt;BR /&gt;LCDtext[8] = upper_chr (Seconds);&lt;BR /&gt;LCDtext[9] = lower_chr (Seconds);&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;BR /&gt;printf_LCD_4bits (1,1,LCDtext);&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Arial"&gt;I hope this clarifies the situation.&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Arial"&gt;Regards,&lt;BR /&gt;Mac&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Arial"&gt;&lt;BR /&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;Message Edited by bigmac on &lt;SPAN class="date_text"&gt;05-18-2006&lt;/SPAN&gt;&lt;SPAN class="time_text"&gt;05:51 PM&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 18 May 2006 14:39:40 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/PROBLEM-WITH-DS1307/m-p/136160#M4240</guid>
      <dc:creator>bigmac</dc:creator>
      <dc:date>2006-05-18T14:39:40Z</dc:date>
    </item>
    <item>
      <title>Re: PROBLEM WITH DS1307</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/PROBLEM-WITH-DS1307/m-p/136161#M4241</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;Dear friend Bigmac:&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Thank you very much for your support ,help and great explanation.I`ll get this in practice and I tell you later.Every day&amp;nbsp;I learn something.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;have a nice week!&lt;IMG alt=":smileywink:" class="emoticon emoticon-smileywink" id="smileywink" src="http://freescale.i.lithium.com/i/smilies/16x16_smiley-wink.gif" title="Smiley Wink" /&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Ganimides&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 18 May 2006 21:40:28 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/PROBLEM-WITH-DS1307/m-p/136161#M4241</guid>
      <dc:creator>ganimides</dc:creator>
      <dc:date>2006-05-18T21:40:28Z</dc:date>
    </item>
  </channel>
</rss>

