{"id":211,"date":"2019-05-16T00:48:33","date_gmt":"2019-05-15T19:18:33","guid":{"rendered":"https:\/\/tangentmotorsport.com\/?p=211"},"modified":"2019-05-16T00:54:56","modified_gmt":"2019-05-15T19:24:56","slug":"eeprom-fun","status":"publish","type":"post","link":"https:\/\/blogs.tangentmotorsport.com\/?p=211","title":{"rendered":"EEPROM fun"},"content":{"rendered":"\n<p>I had to program a legacy EEPROM on a Mercedes EDC15 ECU. I had a choice: to buy a reliable tool to read\/write the E2P(3SP08\/95SP08) or make my own by reading the datasheet. I chose the 2nd option.<\/p>\n\n\n\n<!--more Keep on Reading!-->\n\n\n\n<p>This particular E2P isn&#8217;t supported by any opensource libraries(it&#8217;s very old), so the first thing I had to figure out was how the SPI was to be configured. Data\/instructions are sent MSB first. Clock is low when idle and data is sampled on leading edge of clock. This means it&#8217;s Mode 0 SPI(CPOL = 0, CPHA = 0). This E2P had a max SPI clock of 2MHz, to be safe I used the slowest clock mode on arduino:<\/p>\n\n\n\n<p>SPCR = (1&lt;&lt;SPE)|(1&lt;&lt;MSTR)|(1&lt;&lt;SPR1)|(1&lt;&lt;SPR0);<\/p>\n\n\n\n<p>The opcodes for the instructions were special on this E2P: <\/p>\n\n\n\n<a href=\"https:\/\/imgur.com\/xM1nLiW\"><img decoding=\"async\" src=\"https:\/\/i.imgur.com\/xM1nLiW.png\" title=\"source: imgur.com\"><\/a>\n\n\n\n<p>The 2 MSb&#8217;s of the address(A9, A8) were to be encoded with the READ\/WRITE opcode. I wrote these functions for R\/W of this E2P on arduino:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">byte read_eeprom(int EEPROM_address)<br>\n{<br>\n  \/\/READ EEPROM<br>\n  int data;<br>\n  digitalWrite(SLAVESELECT,LOW);<br>\n  \/\/ bit A8 and A9 are copied to bit pos 4 and 5 of READ\/WRITE opcode<br>\n  byte A8A9=(byte)((EEPROM_address &amp; 0x300) &gt;&gt; 5);<br>\n  spi_transfer(READ | A8A9); \/\/transmit read opcode<br>\n  spi_transfer((byte)(EEPROM_address));      \/\/send LSByte address<br>\n  data = spi_transfer(0xFF); \/\/get data byte<br>\n  digitalWrite(SLAVESELECT,HIGH); \/\/release chip, signal end transfer<br>\n  return data;<br>\n}<\/pre>\n\n\n\n<pre class=\"wp-block-preformatted\">void write_eeprom(int EEPROM_address, char data)<br>\n{<br>\n  \/\/WRITE EEPROM<br>\n  digitalWrite(SLAVESELECT,LOW);<br>\n  spi_transfer(WREN);<br>\n  digitalWrite(SLAVESELECT,HIGH);<br>\n  delay(5);<br>\n  digitalWrite(SLAVESELECT,LOW);<br>\n  \/\/ bit A8 and A9 are copied to bit pos 4 and 5 of READ\/WRITE opcode<br>\n  byte A8A9=(byte)((EEPROM_address &amp; 0x300) &gt;&gt; 5);<br>\n  spi_transfer(WRITE | A8A9); \/\/transmit read opcode<br>\n  spi_transfer((byte)(EEPROM_address));      \/\/send LSByte address<br>\n  spi_transfer(data); \/\/write data byte<br>\n  digitalWrite(SLAVESELECT,HIGH); \/\/release chip, signal end transfer<br>\n  delay(5);<br>\n}<\/pre>\n\n\n\n<p>The delays in the write function are to follow the timing diagrams in the datasheet:<\/p>\n\n\n\n<a href=\"https:\/\/imgur.com\/TLyjlNY\"><img decoding=\"async\" src=\"https:\/\/i.imgur.com\/TLyjlNY.png\" title=\"source: imgur.com\"><\/a>\n\n\n\n<p>I was in a rush to test this out, here&#8217;s the wiring:<\/p>\n\n\n\n<a href=\"https:\/\/imgur.com\/mpELgjR\"><img decoding=\"async\" src=\"https:\/\/i.imgur.com\/mpELgjR.jpg\" title=\"source: imgur.com\"><\/a>\n\n\n\n<p>Now, I&#8217;ll be testing an Immobiliser delete for this engine(never been made before by anyone \ud83d\ude09 ), lying in my backyard:<\/p>\n\n\n\n<a href=\"https:\/\/imgur.com\/MJs3nQs\"><img decoding=\"async\" src=\"https:\/\/i.imgur.com\/MJs3nQs.jpg\" title=\"source: imgur.com\"><\/a>\n\n\n\n<p><\/p>\n\n\n\n<p><br><\/p>\n","protected":false},"excerpt":{"rendered":"<p>I had to program a legacy EEPROM on a Mercedes EDC15 ECU. I had a choice: to buy a reliable tool to read\/write the E2P(3SP08\/95SP08) or make my own by reading the datasheet. I chose the 2nd option.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"om_disable_all_campaigns":false,"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[6,5],"tags":[62,64,61,63,59,60],"class_list":["post-211","post","type-post","status-publish","format-standard","hentry","category-cr","category-re","tag-bosch","tag-e2p","tag-edc15c","tag-eeprom","tag-immo-off","tag-mercedes"],"aioseo_notices":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.8 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>EEPROM fun -<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/03-127-164-11.cprapid.com\/?p=211\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"EEPROM fun -\" \/>\n<meta property=\"og:description\" content=\"I had to program a legacy EEPROM on a Mercedes EDC15 ECU. I had a choice: to buy a reliable tool to read\/write the E2P(3SP08\/95SP08) or make my own by reading the datasheet. I chose the 2nd option.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/03-127-164-11.cprapid.com\/?p=211\" \/>\n<meta property=\"article:published_time\" content=\"2019-05-15T19:18:33+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2019-05-15T19:24:56+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/i.imgur.com\/xM1nLiW.png\" \/>\n<meta name=\"author\" content=\"nihalot\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"nihalot\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/03-127-164-11.cprapid.com\/?p=211\",\"url\":\"https:\/\/03-127-164-11.cprapid.com\/?p=211\",\"name\":\"EEPROM fun -\",\"isPartOf\":{\"@id\":\"https:\/\/blogs.tangentmotorsport.com\/#website\"},\"datePublished\":\"2019-05-15T19:18:33+00:00\",\"dateModified\":\"2019-05-15T19:24:56+00:00\",\"author\":{\"@id\":\"https:\/\/blogs.tangentmotorsport.com\/#\/schema\/person\/d90d31ae9d843a5f8308048a2f2d19f0\"},\"breadcrumb\":{\"@id\":\"https:\/\/03-127-164-11.cprapid.com\/?p=211#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/03-127-164-11.cprapid.com\/?p=211\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/03-127-164-11.cprapid.com\/?p=211#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/blogs.tangentmotorsport.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"EEPROM fun\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/blogs.tangentmotorsport.com\/#website\",\"url\":\"https:\/\/blogs.tangentmotorsport.com\/\",\"name\":\"\",\"description\":\"Custom Code for ECUs\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/blogs.tangentmotorsport.com\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/blogs.tangentmotorsport.com\/#\/schema\/person\/d90d31ae9d843a5f8308048a2f2d19f0\",\"name\":\"nihalot\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/blogs.tangentmotorsport.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/cbff731b9289c11fc7eeba59d92f76462697573bbfb1b8b22fe4e2a20558750c?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/cbff731b9289c11fc7eeba59d92f76462697573bbfb1b8b22fe4e2a20558750c?s=96&d=mm&r=g\",\"caption\":\"nihalot\"},\"url\":\"https:\/\/blogs.tangentmotorsport.com\/?author=1\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"EEPROM fun -","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/03-127-164-11.cprapid.com\/?p=211","og_locale":"en_US","og_type":"article","og_title":"EEPROM fun -","og_description":"I had to program a legacy EEPROM on a Mercedes EDC15 ECU. I had a choice: to buy a reliable tool to read\/write the E2P(3SP08\/95SP08) or make my own by reading the datasheet. I chose the 2nd option.","og_url":"https:\/\/03-127-164-11.cprapid.com\/?p=211","article_published_time":"2019-05-15T19:18:33+00:00","article_modified_time":"2019-05-15T19:24:56+00:00","og_image":[{"url":"https:\/\/i.imgur.com\/xM1nLiW.png"}],"author":"nihalot","twitter_card":"summary_large_image","twitter_misc":{"Written by":"nihalot","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/03-127-164-11.cprapid.com\/?p=211","url":"https:\/\/03-127-164-11.cprapid.com\/?p=211","name":"EEPROM fun -","isPartOf":{"@id":"https:\/\/blogs.tangentmotorsport.com\/#website"},"datePublished":"2019-05-15T19:18:33+00:00","dateModified":"2019-05-15T19:24:56+00:00","author":{"@id":"https:\/\/blogs.tangentmotorsport.com\/#\/schema\/person\/d90d31ae9d843a5f8308048a2f2d19f0"},"breadcrumb":{"@id":"https:\/\/03-127-164-11.cprapid.com\/?p=211#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/03-127-164-11.cprapid.com\/?p=211"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/03-127-164-11.cprapid.com\/?p=211#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/blogs.tangentmotorsport.com\/"},{"@type":"ListItem","position":2,"name":"EEPROM fun"}]},{"@type":"WebSite","@id":"https:\/\/blogs.tangentmotorsport.com\/#website","url":"https:\/\/blogs.tangentmotorsport.com\/","name":"","description":"Custom Code for ECUs","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/blogs.tangentmotorsport.com\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/blogs.tangentmotorsport.com\/#\/schema\/person\/d90d31ae9d843a5f8308048a2f2d19f0","name":"nihalot","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/blogs.tangentmotorsport.com\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/cbff731b9289c11fc7eeba59d92f76462697573bbfb1b8b22fe4e2a20558750c?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/cbff731b9289c11fc7eeba59d92f76462697573bbfb1b8b22fe4e2a20558750c?s=96&d=mm&r=g","caption":"nihalot"},"url":"https:\/\/blogs.tangentmotorsport.com\/?author=1"}]}},"_links":{"self":[{"href":"https:\/\/blogs.tangentmotorsport.com\/index.php?rest_route=\/wp\/v2\/posts\/211","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blogs.tangentmotorsport.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.tangentmotorsport.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.tangentmotorsport.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.tangentmotorsport.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=211"}],"version-history":[{"count":0,"href":"https:\/\/blogs.tangentmotorsport.com\/index.php?rest_route=\/wp\/v2\/posts\/211\/revisions"}],"wp:attachment":[{"href":"https:\/\/blogs.tangentmotorsport.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=211"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.tangentmotorsport.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=211"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.tangentmotorsport.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=211"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}