{"id":311,"date":"2017-11-23T20:57:47","date_gmt":"2017-11-23T19:57:47","guid":{"rendered":"http:\/\/mikrocontroller.bplaced.net\/wordpress\/?page_id=311"},"modified":"2017-12-30T19:30:08","modified_gmt":"2017-12-30T18:30:08","slug":"14-i2c_lolevel-library-stm32f429","status":"publish","type":"page","link":"https:\/\/mikrocontroller.bplaced.net\/wordpress\/?page_id=311","title":{"rendered":"14-I2C_LoLevel-Library (STM32F429)"},"content":{"rendered":"<p><div id=\"nav-below\" class=\"navigation\"><div class=\"nav-previous\"><a href=\"https:\/\/mikrocontroller.bplaced.net\/wordpress\/?page_id=309\" title=\"13-USB_CDC-Library (STM32F429)\"><span class=\"meta-nav\">\u2190<\/span> 13-USB_CDC-Library (STM32F429)<\/a><\/div><\/div><!-- #nav-below --><div id=\"nav-below\" class=\"navigation\"><div class=\"nav-next\"><a href=\"https:\/\/mikrocontroller.bplaced.net\/wordpress\/?page_id=313\" title=\"15-Touch_STMPE811-Library (STM32F429)\">15-Touch_STMPE811-Library (STM32F429) <span class=\"meta-nav\">&rarr;<\/span><\/a><\/div><\/div><!-- #nav-below --><\/p>\n<p>diese Library dient zum benutzen der I2C-Schnittstelle im Master-Mode<\/p>\n<p>die I2C-Pins die benutzt werden sollen, m\u00fcssen im C-File eingetragen werden<br \/>\n(im H-File kann die I2C-Clock-Frq eingestellt werden)<\/p>\n<p>auf der Hardware d\u00fcrfen die zwei externen Pull-Up Widerst\u00e4nde (je 4k7) an SCL und SDA nicht vergessen werden, sonst funktioniert das ganze nicht.<\/p>\n<p>die Library kann als LoLevel-Funktion die Schnittstelle initialisieren und Daten zu einem Slave senden und von einem Slave empfangen.<\/p>\n<p>es gibt Funktionen um ein einzelnes Datenbyte zu senden\/empfangen und Funktionen um mehrere Bytes zu senden\/empfangen. In dem Fall m\u00fc\u00dfen die Daten vor dem senden in einem Array stehen bzw. stehen nach dem empfangen in einem Array.<\/p>\n<p>Die Funktion \u201cUB_I2C1_WriteCMD\u201d sendet nur ein einzelnes Byte an den Slave.<\/p>\n<p>es gibt auch noch eine \u201cPausenfunktion\u201d was einfach nur ein Z\u00e4hler auf 0 ist um z.B. f\u00fcr langsame I2C-Devives eine Wartefunktion einf\u00fcgen zu k\u00f6nnen.<\/p>\n<p>es gibt 3 identische Librarys, getrennt f\u00fcr I2C1, I2C2 und I2C3<\/p>\n<p>im Beispiel wurde I2C3 benutzt mit dieser Pinbelegung :<\/p>\n<pre lang=\"c\" line=\"1\">SCL an PA8\r\nSDA an PC9<\/pre>\n<p><strong><strong>Funktionen (f\u00fcr I2C1) :<\/strong><\/strong><\/p>\n<pre lang=\"c\" line=\"1\">void UB_I2C1_Init(void);                                                     \/\/ zum initialisieren der I2C-Schnittstelle\r\nint16_t UB_I2C1_ReadByte(uint8_t slave_adr, uint8_t adr);                    \/\/ um ein Byte zu lesen\r\nint16_t UB_I2C1_WriteByte(uint8_t slave_adr, uint8_t adr, uint8_t wert);     \/\/ zum ein Byte zu schreiben\r\nint16_t UB_I2C1_ReadMultiByte(uint8_t slave_adr, uint8_t adr, uint8_t cnt);  \/\/ um mehrere Bytes zu lesen\r\nint16_t UB_I2C1_WriteMultiByte(uint8_t slave_adr, uint8_t adr, uint8_t cnt); \/\/ um mehrere Bytes zu schreiben\r\nint16_t UB_I2C1_WriteCMD(uint8_t slave_adr, uint8_t cmd);                    \/\/ ein einzelnes Byte senden\r\nint16_t UB_I2C1_ReadByte16(uint8_t slave_adr, uint16_t adr);                 \/\/ 16bit adresse auslesen\r\nint16_t UB_I2C1_WriteByte16(uint8_t slave_adr, uint16_t adr, uint8_t wert);  \/\/ 16bit adresse beschreiben\r\nvoid UB_I2C1_Delay(volatile uint32_t nCount);                                \/\/ Pausenfunktion<\/pre>\n<p><strong>Beispiel :<\/strong><\/p>\n<pre lang=\"c\" line=\"1\">\/\/--------------------------------------------------------------\r\n\/\/ File     : main.c\r\n\/\/ Datum    : 03.11.2013\r\n\/\/ Version  : 1.0\r\n\/\/ Autor    : UB\r\n\/\/ EMail    : mc-4u(@)t-online.de\r\n\/\/ Web      : www.mikrocontroller-4u.de\r\n\/\/ CPU      : STM32F429\r\n\/\/ IDE      : CooCox CoIDE 1.7.4\r\n\/\/ GCC      : 4.7 2012q4\r\n\/\/ Module   : CMSIS_BOOT, M4_CMSIS_CORE\r\n\/\/ Funktion : Demo der I2C-LoLevel-Library\r\n\/\/ Hinweis  : Diese zwei Files muessen auf 8MHz stehen\r\n\/\/              \"cmsis_boot\/stm32f4xx.h\"\r\n\/\/              \"cmsis_boot\/system_stm32f4xx.c\"\r\n\/\/ In Configuration diese Define hinzuf\u00fcgen :\r\n\/\/ \"STM32F429_439xx\" , \"__ASSEMBLY__\" , \"USE_STDPERIPH_DRIVER\"\r\n\/\/--------------------------------------------------------------\r\n\r\n#include \"main.h\"\r\n#include \"stm32_ub_i2c3.h\"\r\n\r\nint main(void)\r\n{\r\n  int16_t wert;\r\n\r\n  SystemInit(); \/\/ Quarz Einstellungen aktivieren\r\n\r\n  \/\/ Init der I2C1-Schnittstelle\r\n  UB_I2C3_Init();\r\n\r\n  \/\/ ein Byte vom I2C-Slave mit Adr 0xA0\r\n  \/\/ aus Register-Adr 0x01 auslesen\r\n  wert=UB_I2C3_ReadByte(0xA0,0x01);\r\n  if(wert&lt;0) {\r\n    \/\/ Fehler\r\n  }\r\n\r\n  \/\/ den Wert 0x12 zum I2C-Slave mit Adr 0xC0\r\n  \/\/ in Register-Adr 0x02 speichern\r\n  wert=UB_I2C3_WriteByte(0xC0,0x02,0x12);\r\n  if(wert&lt;0) {\r\n    \/\/ Fehler\r\n  }\r\n\r\n  UB_I2C3_Delay(400); \/\/ kleine Pause nach dem schreiben\r\n\r\n  while(1)\r\n  {\r\n\r\n  }\r\n}\r\n<\/pre>\n<p>Hier die Library zum\u00a0<strong>Download :<\/strong><\/p>\n<p><a href=\"wp-content\/uploads\/2016\/02\/i2c_master_f429_v103.zip\">i2c_master_f429_v103<\/a><\/p>\n<p>Hier der komplette CooCox-Projektordner zum\u00a0<strong>Download :<\/strong><\/p>\n<p><a href=\"wp-content\/uploads\/2016\/02\/Demo_F429_14.zip\">Demo_F429_14<\/a><\/p>\n<hr \/>\n<h3 id=\"comments-title\">19 Antworten auf <em>14-I2C_LoLevel-Library (STM32F429)<\/em><\/h3>\n<ol class=\"commentlist\">\n<li id=\"li-comment-1625\" class=\"comment even thread-even depth-1\">\n<div id=\"comment-1625\">\n<div class=\"comment-author vcard\"><img loading=\"lazy\" decoding=\"async\" class=\"avatar avatar-40 photo\" src=\"http:\/\/1.gravatar.com\/avatar\/dec1051001cef3df5d5bed728a6cbd9f?s=40&amp;d=http%3A%2F%2F1.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D40&amp;r=G\" alt=\"\" width=\"40\" height=\"40\" \/><cite class=\"fn\">kostas<\/cite> <span class=\"says\">sagt:<\/span><\/div>\n<p><!-- .comment-author .vcard --><\/p>\n<div class=\"comment-meta commentmetadata\">2. Mai 2014 um 22:48<\/div>\n<p><!-- .comment-meta .commentmetadata --><\/p>\n<div class=\"comment-body\">\n<p>Sir, im having problem using the I2C1 on stm32f429<br \/>\nNot just with your library but with ST too.<br \/>\nI dont know what mistake im doing but i think i get no data from I2C.<br \/>\nIm using a lux sensor BH1750, its working ok using arduino.<br \/>\nI uploaded the source file here<br \/>\n<a href=\"https:\/\/github.com\/papadkostas\/STM32F429\/blob\/master\/main.c\" rel=\"nofollow\">https:\/\/github.com\/papadkostas\/STM32F429\/blob\/master\/main.c<\/a><br \/>\nThe arduino code looks like this<br \/>\nuint16_t level;<br \/>\nWire.beginTransmission(0\u00d723);<br \/>\nWire.requestFrom(0\u00d723, 2);<br \/>\nlevel = Wire.read();<br \/>\nlevel &lt;&lt;= 8;<br \/>\nlevel |= Wire.read();<br \/>\nWire.endTransmission();<br \/>\nAlso im using the pull up 4K7 resistors for both SDA\/SCL.<br \/>\nIm thinking the communication never occurs because after debuging the code found that @UB_I2C3_WriteByte.c Line 200 stays there until timeout occurs.<br \/>\nThought you might see what im doing wrong here<br \/>\nThanks in advance.<br \/>\nKostas.<\/p>\n<\/div>\n<\/div>\n<p><!-- #comment-## --><\/p>\n<ul class=\"children\">\n<li id=\"li-comment-1627\" class=\"comment byuser comment-author-admin_ub bypostauthor odd alt depth-2\">\n<div id=\"comment-1627\">\n<div class=\"comment-author vcard\"><img loading=\"lazy\" decoding=\"async\" class=\"avatar avatar-40 photo\" src=\"http:\/\/0.gravatar.com\/avatar\/67426419ead44d5afa132e92685bb460?s=40&amp;d=http%3A%2F%2F0.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D40&amp;r=G\" alt=\"\" width=\"40\" height=\"40\" \/><cite class=\"fn\">admin_ub<\/cite> <span class=\"says\">sagt:<\/span><\/div>\n<p><!-- .comment-author .vcard --><\/p>\n<div class=\"comment-meta commentmetadata\">3. Mai 2014 um 09:34<\/div>\n<p><!-- .comment-meta .commentmetadata --><\/p>\n<div class=\"comment-body\">\n<p>oh thats easy, my SlaveAdress is a 8bit Adress and the Arduino one is 7bit. So just shift 0\u00d723 one bit to the left and you have the right adress <b>0\u00d746<\/b> for my code (and for the st too)<\/p>\n<\/div>\n<\/div>\n<p><!-- #comment-## --><\/li>\n<\/ul>\n<\/li>\n<li id=\"li-comment-1634\" class=\"comment even thread-odd thread-alt depth-1\">\n<div id=\"comment-1634\">\n<div class=\"comment-author vcard\"><img loading=\"lazy\" decoding=\"async\" class=\"avatar avatar-40 photo\" src=\"http:\/\/1.gravatar.com\/avatar\/dec1051001cef3df5d5bed728a6cbd9f?s=40&amp;d=http%3A%2F%2F1.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D40&amp;r=G\" alt=\"\" width=\"40\" height=\"40\" \/><cite class=\"fn\">kostas<\/cite> <span class=\"says\">sagt:<\/span><\/div>\n<p><!-- .comment-author .vcard --><\/p>\n<div class=\"comment-meta commentmetadata\">3. Mai 2014 um 15:21<\/div>\n<p><!-- .comment-meta .commentmetadata --><\/p>\n<div class=\"comment-body\">\n<p>Oh!! i didnt knew this information, you\u2019re right!!<br \/>\nStill on the screen i get the failed message.<br \/>\nScope needed here :\/<\/p>\n<\/div>\n<\/div>\n<p><!-- #comment-## --><\/p>\n<ul class=\"children\">\n<li id=\"li-comment-1635\" class=\"comment odd alt depth-2\">\n<div id=\"comment-1635\">\n<div class=\"comment-author vcard\"><img loading=\"lazy\" decoding=\"async\" class=\"avatar avatar-40 photo\" src=\"http:\/\/1.gravatar.com\/avatar\/dec1051001cef3df5d5bed728a6cbd9f?s=40&amp;d=http%3A%2F%2F1.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D40&amp;r=G\" alt=\"\" width=\"40\" height=\"40\" \/><cite class=\"fn\">kostas<\/cite> <span class=\"says\">sagt:<\/span><\/div>\n<p><!-- .comment-author .vcard --><\/p>\n<div class=\"comment-meta commentmetadata\">3. Mai 2014 um 18:50<\/div>\n<p><!-- .comment-meta .commentmetadata --><\/p>\n<div class=\"comment-body\">\n<p>I think using screen and touch sensor blocking the pins for i2c operation.<br \/>\nRight?<br \/>\nI have uploaded the whole project here<br \/>\n<a href=\"https:\/\/github.com\/papadkostas\/BH1750_UB\" rel=\"nofollow\">https:\/\/github.com\/papadkostas\/BH1750_UB<\/a><\/p>\n<\/div>\n<\/div>\n<p><!-- #comment-## --><\/p>\n<ul class=\"children\">\n<li id=\"li-comment-1636\" class=\"comment byuser comment-author-admin_ub bypostauthor even depth-3\">\n<div id=\"comment-1636\">\n<div class=\"comment-author vcard\"><img loading=\"lazy\" decoding=\"async\" class=\"avatar avatar-40 photo\" src=\"http:\/\/0.gravatar.com\/avatar\/67426419ead44d5afa132e92685bb460?s=40&amp;d=http%3A%2F%2F0.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D40&amp;r=G\" alt=\"\" width=\"40\" height=\"40\" \/><cite class=\"fn\">admin_ub<\/cite> <span class=\"says\">sagt:<\/span><\/div>\n<p><!-- .comment-author .vcard --><\/p>\n<div class=\"comment-meta commentmetadata\">3. Mai 2014 um 19:42<\/div>\n<p><!-- .comment-meta .commentmetadata --><\/p>\n<div class=\"comment-body\">\n<p>i2c is a multi slave bus. So you can use both devices at the same time (touch and BH1750). The pull Up resistors for I2C3 are already on the disco board, so don\u2019t connect external pull ups for this channel. Use a scope to check the signals PA8 = Clock, PC9 = DATA. And keep the wires as short as possible. Perhaps you need a delay after \u201cUB_I2C3_WriteByte(0\u00d723&lt;&lt;1,0\u00d700,0\u00d710);\u201d and whats the return code of this function ?<\/p>\n<\/div>\n<\/div>\n<p><!-- #comment-## --><\/p>\n<ul class=\"children\">\n<li id=\"li-comment-1637\" class=\"comment odd alt depth-4\">\n<div id=\"comment-1637\">\n<div class=\"comment-author vcard\"><img loading=\"lazy\" decoding=\"async\" class=\"avatar avatar-40 photo\" src=\"http:\/\/1.gravatar.com\/avatar\/dec1051001cef3df5d5bed728a6cbd9f?s=40&amp;d=http%3A%2F%2F1.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D40&amp;r=G\" alt=\"\" width=\"40\" height=\"40\" \/><cite class=\"fn\">kostas<\/cite> <span class=\"says\">sagt:<\/span><\/div>\n<p><!-- .comment-author .vcard --><\/p>\n<div class=\"comment-meta commentmetadata\">4. Mai 2014 um 00:18<\/div>\n<p><!-- .comment-meta .commentmetadata --><\/p>\n<div class=\"comment-body\">\n<p>Well, it returns -2 not matter what im doing<br \/>\neven with or without the sensor connected to the bus.<br \/>\nCables are about 10cm, is the same i\u2019ve used with arduino.<br \/>\nI updated the code to print init errors too.<br \/>\nIts really a big mystery on whats going on here.<br \/>\nI think its something wrong with the address on slave.<br \/>\nUB_I2C3_WriteByte(0\u00d723&lt;&lt;1,0\u00d700,0\u00d710);<br \/>\nWith arduino im not sending any address.<br \/>\nFirst i only request transmision to slave, and then sending the data for register.<br \/>\nAm i thinking wrong?<br \/>\nThanks for your time!!<\/p>\n<\/div>\n<\/div>\n<p><!-- #comment-## --><\/p>\n<ul class=\"children\">\n<li id=\"li-comment-1638\" class=\"comment even depth-5\">\n<div id=\"comment-1638\">\n<div class=\"comment-author vcard\"><img loading=\"lazy\" decoding=\"async\" class=\"avatar avatar-40 photo\" src=\"http:\/\/1.gravatar.com\/avatar\/b894d67379dd0647dd316009f47155d2?s=40&amp;d=http%3A%2F%2F1.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D40&amp;r=G\" alt=\"\" width=\"40\" height=\"40\" \/><cite class=\"fn\">Joerg B.<\/cite> <span class=\"says\">sagt:<\/span><\/div>\n<p><!-- .comment-author .vcard --><\/p>\n<div class=\"comment-meta commentmetadata\">4. Mai 2014 um 07:25<\/div>\n<p><!-- .comment-meta .commentmetadata --><\/p>\n<div class=\"comment-body\">\n<p>Hello Kostas,<br \/>\nDid You use a stm32f4 discoveryboard?<\/p>\n<p>Did You use the breakout board for Your BH1750?<\/p>\n<p>Be sure there are only ONE Pull Up on SCL and SDA Line. Refer Schematics of all Boards You use.<\/p>\n<p>Use the Adress acording the ADD Pin of the bh1750. Refer Datasheet.<\/p>\n<p>Have a look to the Arduino Code and than be sure Your code does the same as arduino code.<\/p>\n<p>Good luck !<\/p>\n<p>Joerg<\/p>\n<\/div>\n<\/div>\n<p><!-- #comment-## --><\/li>\n<li id=\"li-comment-1639\" class=\"comment odd alt depth-5\">\n<div id=\"comment-1639\">\n<div class=\"comment-author vcard\"><img loading=\"lazy\" decoding=\"async\" class=\"avatar avatar-40 photo\" src=\"http:\/\/1.gravatar.com\/avatar\/b894d67379dd0647dd316009f47155d2?s=40&amp;d=http%3A%2F%2F1.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D40&amp;r=G\" alt=\"\" width=\"40\" height=\"40\" \/><cite class=\"fn\">Joerg B.<\/cite> <span class=\"says\">sagt:<\/span><\/div>\n<p><!-- .comment-author .vcard --><\/p>\n<div class=\"comment-meta commentmetadata\">4. Mai 2014 um 07:33<\/div>\n<p><!-- .comment-meta .commentmetadata --><\/p>\n<div class=\"comment-body\">\n<p>Ok You use the board so You have to remove the Pull Ups on Your breakout Board.<\/p>\n<\/div>\n<\/div>\n<p><!-- #comment-## --><\/li>\n<\/ul>\n<\/li>\n<li id=\"li-comment-1640\" class=\"comment even depth-4\">\n<div id=\"comment-1640\">\n<div class=\"comment-author vcard\"><img loading=\"lazy\" decoding=\"async\" class=\"avatar avatar-40 photo\" src=\"http:\/\/1.gravatar.com\/avatar\/b894d67379dd0647dd316009f47155d2?s=40&amp;d=http%3A%2F%2F1.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D40&amp;r=G\" alt=\"\" width=\"40\" height=\"40\" \/><cite class=\"fn\">Joerg B.<\/cite> <span class=\"says\">sagt:<\/span><\/div>\n<p><!-- .comment-author .vcard --><\/p>\n<div class=\"comment-meta commentmetadata\">4. Mai 2014 um 09:34<\/div>\n<p><!-- .comment-meta .commentmetadata --><\/p>\n<div class=\"comment-body\">\n<p>Why did u shift 1 left the adress???<\/p>\n<p>\u201cstatusinit = UB_I2C3_WriteByte(0\u00d723&lt;&lt;1,0\u00d700,0\u00d710);&#8220;<\/p>\n<\/div>\n<\/div>\n<p><!-- #comment-## --><\/p>\n<ul class=\"children\">\n<li id=\"li-comment-1642\" class=\"comment odd alt depth-5\">\n<div id=\"comment-1642\">\n<div class=\"comment-author vcard\"><img loading=\"lazy\" decoding=\"async\" class=\"avatar avatar-40 photo\" src=\"http:\/\/1.gravatar.com\/avatar\/dec1051001cef3df5d5bed728a6cbd9f?s=40&amp;d=http%3A%2F%2F1.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D40&amp;r=G\" alt=\"\" width=\"40\" height=\"40\" \/><cite class=\"fn\">kostas<\/cite> <span class=\"says\">sagt:<\/span><\/div>\n<p><!-- .comment-author .vcard --><\/p>\n<div class=\"comment-meta commentmetadata\">4. Mai 2014 um 12:54<\/div>\n<p><!-- .comment-meta .commentmetadata --><\/p>\n<div class=\"comment-body\">\n<p>Admin said that this i2c interface<br \/>\nusing 8 bit addressing<br \/>\nand the arduino i2c interface<br \/>\nuse 7bit i2c addressing.<br \/>\nSo i had to shift it 1bit to left.<br \/>\nThe LSB is R\/W operation?<br \/>\nYes i removed the external pull up resistors<br \/>\n<a href=\"http:\/\/www.dfrobot.com\/image\/data\/SEN0097\/BH1750FVI.pdf\" rel=\"nofollow\">http:\/\/www.dfrobot.com\/image\/data\/SEN0097\/BH1750FVI.pdf<\/a><br \/>\nIf you see here, page 7 example 1.<br \/>\nTo start continuously measurement<br \/>\nyou have to do the following:<br \/>\n1)Issue START condition<br \/>\n2)Send slave address with write operation bit<br \/>\n3)Wait to Receive ACK<br \/>\n4)Send 1 Byte<br \/>\n5)Wait to Receive ACK<br \/>\n6)Issue STOP condition<br \/>\nI think what the code do is this:<br \/>\n1)Issue START condition<br \/>\n2)Send slave address with write option bit<br \/>\n5)Wait to Receive ACK<br \/>\n5)Send 1 Byte(0\u00d700)<br \/>\n6)Wait to Receive ACK<br \/>\n7)Send 1 Byte(0\u00d710)<br \/>\n8)Wait to Receive ACK<br \/>\n9)Issue STOP condition<\/p>\n<\/div>\n<\/div>\n<p><!-- #comment-## --><\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<li id=\"li-comment-1643\" class=\"comment even thread-even depth-1\">\n<div id=\"comment-1643\">\n<div class=\"comment-author vcard\"><img loading=\"lazy\" decoding=\"async\" class=\"avatar avatar-40 photo\" src=\"http:\/\/1.gravatar.com\/avatar\/dec1051001cef3df5d5bed728a6cbd9f?s=40&amp;d=http%3A%2F%2F1.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D40&amp;r=G\" alt=\"\" width=\"40\" height=\"40\" \/><cite class=\"fn\">kostas<\/cite> <span class=\"says\">sagt:<\/span><\/div>\n<p><!-- .comment-author .vcard --><\/p>\n<div class=\"comment-meta commentmetadata\">4. Mai 2014 um 13:18<\/div>\n<p><!-- .comment-meta .commentmetadata --><\/p>\n<div class=\"comment-body\">\n<p>Now im getting -5 return from statusinit = UB_I2C3_WriteByte(0\u00d723&lt;&lt;1,0\u00d700,0\u00d710);<br \/>\nIm searching now what it means.<br \/>\nLooks like its getting closer.<\/p>\n<\/div>\n<\/div>\n<p><!-- #comment-## --><\/p>\n<ul class=\"children\">\n<li id=\"li-comment-1644\" class=\"comment odd alt depth-2\">\n<div id=\"comment-1644\">\n<div class=\"comment-author vcard\"><img loading=\"lazy\" decoding=\"async\" class=\"avatar avatar-40 photo\" src=\"http:\/\/1.gravatar.com\/avatar\/b894d67379dd0647dd316009f47155d2?s=40&amp;d=http%3A%2F%2F1.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D40&amp;r=G\" alt=\"\" width=\"40\" height=\"40\" \/><cite class=\"fn\">Joerg B.<\/cite> <span class=\"says\">sagt:<\/span><\/div>\n<p><!-- .comment-author .vcard --><\/p>\n<div class=\"comment-meta commentmetadata\">4. Mai 2014 um 16:53<\/div>\n<p><!-- .comment-meta .commentmetadata --><\/p>\n<div class=\"comment-body\">\n<p>ok<br \/>\nHave a look for that: <a href=\"http:\/\/davidegironi.blogspot.de\/2013\/02\/light-intensity-lux-measure-using.html#.U2ZTXyhe1sQ\" rel=\"nofollow\">http:\/\/davidegironi.blogspot.de\/2013\/02\/light-intensity-lux-measure-using.html#.U2ZTXyhe1sQ<\/a> its for avr but it should help<\/p>\n<\/div>\n<\/div>\n<p><!-- #comment-## --><\/p>\n<ul class=\"children\">\n<li id=\"li-comment-1651\" class=\"comment even depth-3\">\n<div id=\"comment-1651\">\n<div class=\"comment-author vcard\"><img loading=\"lazy\" decoding=\"async\" class=\"avatar avatar-40 photo\" src=\"http:\/\/1.gravatar.com\/avatar\/dec1051001cef3df5d5bed728a6cbd9f?s=40&amp;d=http%3A%2F%2F1.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D40&amp;r=G\" alt=\"\" width=\"40\" height=\"40\" \/><cite class=\"fn\">kostas<\/cite> <span class=\"says\">sagt:<\/span><\/div>\n<p><!-- .comment-author .vcard --><\/p>\n<div class=\"comment-meta commentmetadata\">5. Mai 2014 um 19:27<\/div>\n<p><!-- .comment-meta .commentmetadata --><\/p>\n<div class=\"comment-body\">\n<p>here is what scope showed to me today<br \/>\n<a href=\"..\/..\/oi62.tinypic.com\/xo1wjo.jpg\" rel=\"nofollow\">http:\/\/oi62.tinypic.com\/xo1wjo.jpg<\/a><br \/>\ni think that is something wrong on the code<br \/>\nbecause address is transmitted ack too and 2 bytes come from slave<\/p>\n<\/div>\n<\/div>\n<p><!-- #comment-## --><\/p>\n<ul class=\"children\">\n<li id=\"li-comment-1652\" class=\"comment byuser comment-author-admin_ub bypostauthor odd alt depth-4\">\n<div id=\"comment-1652\">\n<div class=\"comment-author vcard\"><img loading=\"lazy\" decoding=\"async\" class=\"avatar avatar-40 photo\" src=\"http:\/\/0.gravatar.com\/avatar\/67426419ead44d5afa132e92685bb460?s=40&amp;d=http%3A%2F%2F0.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D40&amp;r=G\" alt=\"\" width=\"40\" height=\"40\" \/><cite class=\"fn\">admin_ub<\/cite> <span class=\"says\">sagt:<\/span><\/div>\n<p><!-- .comment-author .vcard --><\/p>\n<div class=\"comment-meta commentmetadata\">6. Mai 2014 um 08:06<\/div>\n<p><!-- .comment-meta .commentmetadata --><\/p>\n<div class=\"comment-body\">\n<p>no thats not what you see.<br \/>\nYou see the Slave Adress 0\u00d746<br \/>\nthen the Register-Adress 0\u00d700<br \/>\nthen the value 0\u00d710<br \/>\nyou have a bad result because your sensor \u201cBH1750\u2033 dont want a register Adress and so you don\u2019t have to send this adress<br \/>\nyou must change my code and delete the part (in read and write) who send the register adress<\/p>\n<pre lang=\"c\" line=\"1\">  \/\/ Adresse senden\r\n  I2C_SendData(I2C3, adr);\r\n\r\n  timeout=I2C3_TIMEOUT;\r\n  while (!I2C_GetFlagStatus(I2C3, I2C_FLAG_TXE)) {\r\n    if(timeout!=0) timeout--; else return(P_I2C3_timeout(-4));\r\n  }\r\n<\/pre>\n<p>delete these 6 lines in both functions and it should work.<\/p>\n<\/div>\n<\/div>\n<p><!-- #comment-## --><\/p>\n<ul class=\"children\">\n<li id=\"li-comment-1654\" class=\"comment even depth-5\">\n<div id=\"comment-1654\">\n<div class=\"comment-author vcard\"><img loading=\"lazy\" decoding=\"async\" class=\"avatar avatar-40 photo\" src=\"http:\/\/1.gravatar.com\/avatar\/dec1051001cef3df5d5bed728a6cbd9f?s=40&amp;d=http%3A%2F%2F1.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D40&amp;r=G\" alt=\"\" width=\"40\" height=\"40\" \/><cite class=\"fn\">kostas<\/cite> <span class=\"says\">sagt:<\/span><\/div>\n<p><!-- .comment-author .vcard --><\/p>\n<div class=\"comment-meta commentmetadata\">6. Mai 2014 um 10:59<\/div>\n<p><!-- .comment-meta .commentmetadata --><\/p>\n<div class=\"comment-body\">\n<p>Yeah thats what i said code is doing here<br \/>\n5)Send 1 Byte(0\u00d700)<br \/>\n6)Wait to Receive ACK<br \/>\nThose two were useless.<br \/>\nAnyway , im going to try it.<br \/>\nThank you for the guidance finding out whats wrong <img decoding=\"async\" class=\"wp-smiley\" src=\"wp-includes\/images\/smilies\/icon_biggrin.gif\" alt=\":D\" \/> !<br \/>\nI\u2019ll report back if everything is fine.<br \/>\nHave a good day!<\/p>\n<\/div>\n<\/div>\n<p><!-- #comment-## --><\/li>\n<li id=\"li-comment-1661\" class=\"comment odd alt depth-5\">\n<div id=\"comment-1661\">\n<div class=\"comment-author vcard\"><img loading=\"lazy\" decoding=\"async\" class=\"avatar avatar-40 photo\" src=\"http:\/\/1.gravatar.com\/avatar\/dec1051001cef3df5d5bed728a6cbd9f?s=40&amp;d=http%3A%2F%2F1.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D40&amp;r=G\" alt=\"\" width=\"40\" height=\"40\" \/><cite class=\"fn\">kostas<\/cite> <span class=\"says\">sagt:<\/span><\/div>\n<p><!-- .comment-author .vcard --><\/p>\n<div class=\"comment-meta commentmetadata\">7. Mai 2014 um 17:10<\/div>\n<p><!-- .comment-meta .commentmetadata --><\/p>\n<div class=\"comment-body\">\n<p>Everything is fine now, you were right!!<br \/>\nI changed the function, added a flag to tell if i want to send the data to a specific address on the slave or not because its usefull sometimes.<br \/>\nThank you once again!<\/p>\n<\/div>\n<\/div>\n<p><!-- #comment-## --><\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<li id=\"li-comment-1664\" class=\"comment even thread-odd thread-alt depth-1\">\n<div id=\"comment-1664\">\n<div class=\"comment-author vcard\"><img loading=\"lazy\" decoding=\"async\" class=\"avatar avatar-40 photo\" src=\"http:\/\/1.gravatar.com\/avatar\/b894d67379dd0647dd316009f47155d2?s=40&amp;d=http%3A%2F%2F1.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D40&amp;r=G\" alt=\"\" width=\"40\" height=\"40\" \/><cite class=\"fn\">Joerg B.<\/cite> <span class=\"says\">sagt:<\/span><\/div>\n<p><!-- .comment-author .vcard --><\/p>\n<div class=\"comment-meta commentmetadata\">8. Mai 2014 um 19:16<\/div>\n<p><!-- .comment-meta .commentmetadata --><\/p>\n<div class=\"comment-body\">\n<p>Hey Kostas,<br \/>\nplease share Your running code. I have ordered some of the chips from china <img decoding=\"async\" class=\"wp-smiley\" src=\"wp-includes\/images\/smilies\/icon_wink.gif\" alt=\";)\" \/><\/p>\n<p>Joerg<\/p>\n<\/div>\n<\/div>\n<p><!-- #comment-## --><\/p>\n<ul class=\"children\">\n<li id=\"li-comment-1665\" class=\"comment odd alt depth-2\">\n<div id=\"comment-1665\">\n<div class=\"comment-author vcard\"><img loading=\"lazy\" decoding=\"async\" class=\"avatar avatar-40 photo\" src=\"http:\/\/1.gravatar.com\/avatar\/dec1051001cef3df5d5bed728a6cbd9f?s=40&amp;d=http%3A%2F%2F1.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D40&amp;r=G\" alt=\"\" width=\"40\" height=\"40\" \/><cite class=\"fn\">kostas<\/cite> <span class=\"says\">sagt:<\/span><\/div>\n<p><!-- .comment-author .vcard --><\/p>\n<div class=\"comment-meta commentmetadata\">8. Mai 2014 um 21:43<\/div>\n<p><!-- .comment-meta .commentmetadata --><\/p>\n<div class=\"comment-body\">\n<p>Sure, its here <a href=\"https:\/\/github.com\/papadkostas\/BH1750_UB\" rel=\"nofollow\">https:\/\/github.com\/papadkostas\/BH1750_UB<\/a><br \/>\nDownload as zip and go <img decoding=\"async\" class=\"wp-smiley\" src=\"wp-includes\/images\/smilies\/icon_biggrin.gif\" alt=\":D\" \/><\/p>\n<\/div>\n<\/div>\n<p><!-- #comment-## --><\/p>\n<ul class=\"children\">\n<li id=\"li-comment-1690\" class=\"comment even depth-3\">\n<div id=\"comment-1690\">\n<div class=\"comment-author vcard\"><img loading=\"lazy\" decoding=\"async\" class=\"avatar avatar-40 photo\" src=\"http:\/\/1.gravatar.com\/avatar\/b894d67379dd0647dd316009f47155d2?s=40&amp;d=http%3A%2F%2F1.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D40&amp;r=G\" alt=\"\" width=\"40\" height=\"40\" \/><cite class=\"fn\">Joerg B<\/cite> <span class=\"says\">sagt:<\/span><\/div>\n<p><!-- .comment-author .vcard --><\/p>\n<div class=\"comment-meta commentmetadata\">10. Mai 2014 um 16:38<\/div>\n<p><!-- .comment-meta .commentmetadata --><\/p>\n<div class=\"comment-body\">\n<p>Thanks, but I have tom wait for the Chinese post :\/<\/p>\n<\/div>\n<\/div>\n<p><!-- #comment-## --><\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n","protected":false},"excerpt":{"rendered":"<p>diese Library dient zum benutzen der I2C-Schnittstelle im Master-Mode die I2C-Pins die benutzt werden sollen, m\u00fcssen im C-File eingetragen werden (im H-File kann die I2C-Clock-Frq eingestellt werden) auf der Hardware d\u00fcrfen die zwei externen Pull-Up Widerst\u00e4nde (je 4k7) an SCL &hellip; <a href=\"https:\/\/mikrocontroller.bplaced.net\/wordpress\/?page_id=311\">Weiterlesen <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":3,"featured_media":0,"parent":160,"menu_order":14,"comment_status":"open","ping_status":"closed","template":"","meta":{"footnotes":""},"categories":[129],"tags":[98,9,102],"class_list":["post-311","page","type-page","status-publish","hentry","category-stm32f429","tag-i2c","tag-library","tag-stm32f429"],"_links":{"self":[{"href":"https:\/\/mikrocontroller.bplaced.net\/wordpress\/index.php?rest_route=\/wp\/v2\/pages\/311","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/mikrocontroller.bplaced.net\/wordpress\/index.php?rest_route=\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/mikrocontroller.bplaced.net\/wordpress\/index.php?rest_route=\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/mikrocontroller.bplaced.net\/wordpress\/index.php?rest_route=\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/mikrocontroller.bplaced.net\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=311"}],"version-history":[{"count":3,"href":"https:\/\/mikrocontroller.bplaced.net\/wordpress\/index.php?rest_route=\/wp\/v2\/pages\/311\/revisions"}],"predecessor-version":[{"id":1675,"href":"https:\/\/mikrocontroller.bplaced.net\/wordpress\/index.php?rest_route=\/wp\/v2\/pages\/311\/revisions\/1675"}],"up":[{"embeddable":true,"href":"https:\/\/mikrocontroller.bplaced.net\/wordpress\/index.php?rest_route=\/wp\/v2\/pages\/160"}],"wp:attachment":[{"href":"https:\/\/mikrocontroller.bplaced.net\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=311"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mikrocontroller.bplaced.net\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=311"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mikrocontroller.bplaced.net\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=311"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}