<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://community.arm.com/utility/feedstylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Problem reading DS1307</title><link>https://community.arm.com/developer/tools-software/tools/f/keil-forum/41031/problem-reading-ds1307</link><description> 
Hi, 

 
I am using the DS1307 library for STM32L152. The original library
for STM32F429 is at here: 

 stm32f4-discovery.com/.../ 

 
It seems a complete library however after few modification to
STM32L I cant read/write DS1307. 
what ever is received</description><dc:language>en-US</dc:language><generator>Telligent Community 10</generator><item><title>RE: Problem reading DS1307</title><link>https://community.arm.com/thread/133927?ContentTypeID=1</link><pubDate>Sun, 19 Jul 2015 08:31:57 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:21335062-9bc3-4e58-a27e-d5de1994c51e</guid><dc:creator>hamed ad</dc:creator><description>&lt;p&gt;&lt;p&gt;
Oh my God!!&lt;/p&gt;

&lt;p&gt;
DS1307 supply voltage is 4.5-5.5V. this was the problem.&lt;br /&gt;
After changing the supply from 3.3V to 5V the problem solved :)&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Problem reading DS1307</title><link>https://community.arm.com/thread/133930?ContentTypeID=1</link><pubDate>Sun, 19 Jul 2015 07:22:28 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:db02c5a3-f82a-4e5a-86b3-dd429da13dc4</guid><dc:creator>hamed ad</dc:creator><description>&lt;p&gt;&lt;p&gt;
I tried a modification on the code written for eeprom. I see that
I don&amp;#39;t receive ack for address sent and in the debugger ADDR is
never set so where is probably the problem?&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Problem reading DS1307</title><link>https://community.arm.com/thread/117809?ContentTypeID=1</link><pubDate>Sun, 19 Jul 2015 02:54:04 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:27315c27-4d2c-4ca3-8d57-7e90e5753601</guid><dc:creator>hamed ad</dc:creator><description>&lt;p&gt;&lt;p&gt;
Why this simple code fails to work&lt;/p&gt;

&lt;pre&gt;
while(1)
        {
        TM_I2C_Start(I2C2, 0xD0, 0, I2C_ACK_ENABLE) ; //write mode
        TM_I2C_WriteData(I2C2, 0);                    //select register 0x0
        TM_I2C_Stop(I2C2);                            //stop
        TM_I2C_Start(I2C2, 0xD0, 1, I2C_ACK_ENABLE) ; //read mode
        sec = TM_I2C_ReadNack(I2Cx);
        sprintf(str,&amp;quot; :\r\ns=%u&amp;quot;,sec);
        uart_out_str(str);

        }
&lt;/pre&gt;

&lt;p&gt;
In debugger I get AF=1. why ack failures?&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Problem reading DS1307</title><link>https://community.arm.com/thread/117810?ContentTypeID=1</link><pubDate>Sat, 18 Jul 2015 13:50:48 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:b6d0354d-76bf-4f3a-b5c3-18a969e10875</guid><dc:creator>hamed ad</dc:creator><description>&lt;p&gt;&lt;p&gt;
I found another library which is a little smaller in size. It is
written for STM32F0 but I try to understand below function, is there
a way to transfer it to STM32L1XX?&lt;/p&gt;

&lt;pre&gt;
void I2C_TransferHandling(
I2C_TypeDef *   I2Cx,
uint16_t        Address,
uint8_t         Number_Bytes,
uint32_t        ReloadEndMode,
uint32_t        StartStopMode
)
&lt;/pre&gt;

&lt;p&gt;
Is there equivalent in STM32L1xx?&lt;/p&gt;

&lt;pre&gt;
      void I2C_WrReg(uint8_t Reg, uint8_t Dat){
        while(I2C_GetFlagStatus(DS_I2C, I2C_FLAG_BUSY) == SET);

        I2C_TransferHandling(DS_I2C, DS_ADDR, 1, I2C_Reload_Mode, I2C_Generate_Start_Write);
        while(I2C_GetFlagStatus(DS_I2C, I2C_FLAG_TXIS) == RESET);

        I2C_SendData(DS_I2C, Reg);
        while(I2C_GetFlagStatus(DS_I2C, I2C_FLAG_TCR) == RESET);

        I2C_TransferHandling(DS_I2C, DS_ADDR, 1, I2C_AutoEnd_Mode, I2C_No_StartStop);
        while(I2C_GetFlagStatus(DS_I2C, I2C_FLAG_TXIS) == RESET);

        I2C_SendData(DS_I2C, Dat);
        while(I2C_GetFlagStatus(DS_I2C, I2C_FLAG_STOPF) == RESET);
        I2C_ClearFlag(DS_I2C, I2C_FLAG_STOPF);
}

&lt;/pre&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Problem reading DS1307</title><link>https://community.arm.com/thread/108330?ContentTypeID=1</link><pubDate>Sat, 18 Jul 2015 13:36:03 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:1dc597f2-700c-4e10-bbc6-8ff59b2b66e1</guid><dc:creator>hamed ad</dc:creator><description>&lt;p&gt;&lt;p&gt;
Hi,&lt;br /&gt;
I2C Peripheral clock is enabled and I see the signals in scope.&lt;br /&gt;
Yes I see peripheral registers in debugger they change according to
the program flow.&lt;br /&gt;
No, I have not yet spoken to him. I think problem is at start
function. because program waits there, I2C looks so busy.&lt;/p&gt;

&lt;pre&gt;
/* Wait till I2C is busy */
        TM_I2C_Timeout = TM_I2C_TIMEOUT;
        while (!(I2Cx-&amp;gt;SR1 &amp;amp; I2C_SR1_SB)) {
                if (--TM_I2C_Timeout == 0x00) {
                        return 1;
                }
        }
&lt;/pre&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Problem reading DS1307</title><link>https://community.arm.com/thread/93491?ContentTypeID=1</link><pubDate>Sat, 18 Jul 2015 12:58:07 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:680dc784-43bf-437c-8239-a7362a84a4ae</guid><dc:creator>Westonsupermare Pier</dc:creator><description>&lt;p&gt;&lt;p&gt;
Have you enabled the I2C peripheral clock?&lt;br /&gt;
Can you see the peripheral registers in the debugger?&lt;br /&gt;
Have you spoken to the author of the library?&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Problem reading DS1307</title><link>https://community.arm.com/thread/63932?ContentTypeID=1</link><pubDate>Sat, 18 Jul 2015 10:04:40 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:86bc9ef8-970b-43c2-8686-db2a09615cc1</guid><dc:creator>hamed ad</dc:creator><description>&lt;p&gt;&lt;p&gt;
The problem is at start function. ((/* Wait till I2C is busy */))
program waits till TM_I2C_Timeout equals zero.&lt;/p&gt;

&lt;pre&gt;
int16_t TM_I2C_Start(I2C_TypeDef* I2Cx, uint8_t address, uint8_t direction, uint8_t ack) {
        /* Generate I2C start pulse */
        I2Cx-&amp;gt;CR1 |= I2C_CR1_START;

        /* Wait till I2C is busy */
        TM_I2C_Timeout = TM_I2C_TIMEOUT;
        while (!(I2Cx-&amp;gt;SR1 &amp;amp; I2C_SR1_SB)) {
                if (--TM_I2C_Timeout == 0x00) {
                        return 1;
                }
        }

        /* Enable ack if we select it */
        if (ack) {
                I2Cx-&amp;gt;CR1 |= I2C_CR1_ACK;
        }

        /* Send write/read bit */
        if (direction == I2C_TRANSMITTER_MODE) {
                /* Send address with zero last bit */
                I2Cx-&amp;gt;DR = address &amp;amp; ~I2C_OAR1_ADD0;

                /* Wait till finished */
                TM_I2C_Timeout = TM_I2C_TIMEOUT;
                while (!(I2Cx-&amp;gt;SR1 &amp;amp; I2C_SR1_ADDR)) {
                        if (--TM_I2C_Timeout == 0x00) {
                                return 1;
                        }
                }
        }
        if (direction == I2C_RECEIVER_MODE) {
                /* Send address with 1 last bit */
                I2Cx-&amp;gt;DR = address | I2C_OAR1_ADD0;

                /* Wait till finished */
                TM_I2C_Timeout = TM_I2C_TIMEOUT;
                while (!I2C_CheckEvent(I2Cx, I2C_EVENT_MASTER_RECEIVER_MODE_SELECTED)) {
                        if (--TM_I2C_Timeout == 0x00) {
                                return 1;
                        }
                }
        }

&lt;/pre&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>