{"action":"closed","issue":{"url":"https://api.github.com/repos/ARMmbed/mbed-os/issues/4214","repository_url":"https://api.github.com/repos/ARMmbed/mbed-os","labels_url":"https://api.github.com/repos/ARMmbed/mbed-os/issues/4214/labels{/name}","comments_url":"https://api.github.com/repos/ARMmbed/mbed-os/issues/4214/comments","events_url":"https://api.github.com/repos/ARMmbed/mbed-os/issues/4214/events","html_url":"https://github.com/ARMmbed/mbed-os/issues/4214","id":223493354,"number":4214,"title":"STM32 I2C block writes and block read bugs","user":{"login":"Willem23","id":10687540,"avatar_url":"https://avatars3.githubusercontent.com/u/10687540?v=3","gravatar_id":"","url":"https://api.github.com/users/Willem23","html_url":"https://github.com/Willem23","followers_url":"https://api.github.com/users/Willem23/followers","following_url":"https://api.github.com/users/Willem23/following{/other_user}","gists_url":"https://api.github.com/users/Willem23/gists{/gist_id}","starred_url":"https://api.github.com/users/Willem23/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Willem23/subscriptions","organizations_url":"https://api.github.com/users/Willem23/orgs","repos_url":"https://api.github.com/users/Willem23/repos","events_url":"https://api.github.com/users/Willem23/events{/privacy}","received_events_url":"https://api.github.com/users/Willem23/received_events","type":"User","site_admin":false},"labels":[{"id":328051906,"url":"https://api.github.com/repos/ARMmbed/mbed-os/labels/devices:%20st","name":"devices: st","color":"0052cc","default":false},{"id":28847979,"url":"https://api.github.com/repos/ARMmbed/mbed-os/labels/type:%20bug","name":"type: bug","color":"b60205","default":false}],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":8,"created_at":"2017-04-21T20:51:24Z","updated_at":"2017-07-03T08:58:57Z","closed_at":"2017-07-03T08:58:57Z","body":"### Description\r\n- Type: Bug\r\n- Related issue: `#abc`\r\n- Priority: Major\r\n\r\n---------------------------------------------------------------\r\n## Bug\r\n\r\n**Target**\r\nSTM32 F103 and probably others\r\n\r\n**Expected behavior**\r\nI2C should work properly.\r\n\r\n**Actual behavior**\r\nI2C write fails on first Write after reset, Read fails on every other Read.\r\nAck does correctly report status and returns 1 when the slave is not present.\r\n\r\n**Steps to reproduce**\r\n#include \"mbed.h\"\r\n#define PCF8574_ADDRESS 0x40\r\n\r\nint ack;\r\nuint8_t data = 0xAA;\r\nI2C i2c(I2C_SDA,I2C_SCL); \r\n\r\nDigitalOut led1(LED1); \r\nSerial pc(USBTX, USBRX);\r\n\r\nint main() {\r\n  pc.baud(9600);  \r\n  pc.printf(\"\\n\\r\");\r\n  pc.printf(\"Start I2C test\\n\\r\");  \r\n      \r\n  led1 = 0;\r\n  wait(0.5);  \r\n  led1 = 1;\r\n  wait(0.5);    \r\n  led1 = 0;\r\n    \r\n#if(0)\r\n  // Set Port Expander\r\n  while(1) {\r\n    wait(1.0);\r\n   \r\n    // Write port\r\n    ack = i2c.write(PCF8574_ADDRESS, (char *) &data, 1);\r\n    data++;\r\n  \r\n    // Check error\r\n    pc.printf(\"Write Ack = %d\\n\\r\", ack);  \r\n    if(ack != 0) {\r\n      pc.printf(\"  Write Error\\n\\r\");        \r\n    }      \r\n    led1 = !led1;\r\n  }\r\n#else\r\n  // Get Port Expander\r\n  while(1) {\r\n    wait(1.0);\r\n   \r\n    // Read port\r\n    ack = i2c.read(PCF8574_ADDRESS, (char *) &data, 1);\r\n  \r\n    // Check error\r\n    pc.printf(\"Read Ack = %d\\n\\r\", ack);  \r\n    if(ack != 0) {\r\n      pc.printf(\"  Read Error\\n\\r\");\r\n    }    \r\n    led1 = !led1;\r\n  }\r\n#endif  \r\n}\r\n\r\nResult for Reads from PCF8574 using mbed rev 133 and higher:\r\nStart I2C test\r\nRead Ack = 0\r\nRead Ack = 1\r\n  Read Error\r\nRead Ack = 0\r\nRead Ack = 1\r\n  Read Error\r\nRead Ack = 0\r\nRead Ack = 1\r\n  Read Error\r\nRead Ack = 0\r\nRead Ack = 1\r\n  Read Error\r\n\r\nResult for Writes to PCF8574 using mbed rev 140:\r\nStart I2C test\r\nWrite Ack = 1\r\n  Write Error\r\nWrite Ack = 0\r\nWrite Ack = 0\r\nWrite Ack = 0\r\nWrite Ack = 0\r\nWrite Ack = 0\r\nWrite Ack = 0\r\nWrite Ack = 0\r\n\r\nThe I2C lib worked as expected for mbed 132. Revision 133 starts failing for Read. Revision 140 is broken for Write. Have not yet tested at which revision Write starts to break, Read and Write seem to start having issues at different revisions.. \r\n\r\n**Recommend**\r\nInconsistent behavior should be fixed. Some component Libs now fail because the first Write after reset does not succeed. Some libs fail because they check Ack errors and/or get wrong read values.\r\nSee https://developer.mbed.org/questions/77809/Anyone-got-the-STM32F103RB-working-with-/\r\n"}}
{"actor":{"display_login":"0xc0170"}}