{"id":3390,"date":"2025-04-18T06:29:48","date_gmt":"2025-04-18T06:29:48","guid":{"rendered":"https:\/\/webprojects.cloud\/wordpress\/splatco\/?post_type=spl_knowledgebase&#038;p=3390"},"modified":"2025-06-10T11:04:03","modified_gmt":"2025-06-10T11:04:03","slug":"setting-the-command-byte-waiting-for-an-echo","status":"publish","type":"spl_knowledgebase","link":"https:\/\/webprojects.cloud\/wordpress\/splatco\/knowledgebase\/tutorials-application-notes-and-white-papers\/tutorial-splat-call-home-sx10509-programming\/example-splat-call-home-sandbox-program\/setting-the-command-byte-waiting-for-an-echo\/","title":{"rendered":"Setting the command byte, waiting for an echo"},"content":{"rendered":"\n<figure class=\"wp-block-table is-style-stripes\"><table class=\"has-fixed-layout\"><tbody><tr><td>You need to understand both MultiTrack and SPLat semaphores to understand the following.<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p>Down in the core of the program is a mechanism for setting the Tx command byte (<code>bTxCmd<\/code>\u00a0in the Tx data block) and then waiting for an echo. This consists of a subroutine that is called with the required command byte in the\u00a0<a href=\"https:\/\/webprojects.cloud\/wordpress\/splatco\/knowledgebase\/glossary-of-terms\/#o3808\">X<\/a>\u00a0register, and a semaphore that is set only after the SX10509 has echoed the command. The steps for using this are:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><a href=\"https:\/\/webprojects.cloud\/wordpress\/splatco\/knowledgebase\/glossary-of-terms\/m#o591\">Load<\/a>\u00a0the required command byte into X<\/li>\n\n\n\n<li>Call the subroutine<\/li>\n\n\n\n<li>Wait for the &#8220;all done&#8221; semaphore to get set.<\/li>\n<\/ol>\n\n\n\n<p>The SX10509 will only respond to a different command to the last one processed. For several commands of the same type in a row, the trick is to toggle (invert) bit 7 of the command byte. The subroutine below takes care of that under the hood.<\/p>\n\n\n\n<p>Here&#8217;s the first part of the code. This is the subroutine that gets called in step 2 above, with X set to the command byte.<\/p>\n\n\n\n<p><a href=\"https:\/\/webprojects.cloud\/wordpress\/splatco\/knowledgebase\/tutorials-application-notes-and-white-papers\/cutting-and-pasting-code-from-the-splat-knowledge-base\/\">(Click here<\/a>\u00a0for some tips for working around problems with copy and paste out of Internet Explorer and HTML-help\u00a0<code>(.chm)<\/code>\u00a0files)<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">SCH_SetCommand:\n        Push\n        Recall          bTxCmd\n        Swap\n        Store           bTxCmd\n        Compare\n        GoIfNZ          SCH_SC1         ; g\/ new &lt;&gt; old\n        NotS            7,bTxCmd        ; old = new ... toggle bit 7\nSCH_SC1:\n        ClrS            sSCH_GotEcho    ;Clear the Echo semaphore\n        LaunchTask      tsk_SCH_AckWait ;Task that watches out for an echo.  \n        Return \n\nsSCH_GotEcho:            defSEM          ;Signals completion of a SCH\/Xwire command<\/pre>\n\n\n\n<p>The above code compares the new command with the previous one, which it retrieves from the Tx data block. It then toggles bit 7 if they are the same. Once that is done is clears the &#8220;all done&#8221; semaphore&nbsp;<code>sSCH_GotEcho<\/code>, and launches a task&nbsp;<code>tsk_SCH_AckWait<\/code>&nbsp;that is going to watch for a match between the sent command&nbsp;<code>bTxCmd<\/code>&nbsp;and the received echo byte&nbsp;<code>bRxCmdEcho<\/code>.<\/p>\n\n\n\n<p>Here&#8217;s the &#8220;wait task&#8221;&nbsp;<code>tsk_SCH_AckWait<\/code>:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">tsk_SCH_AckWait:        \n        YieldTask\n        Recall          bTxCmd          ;Get back the command just set\n        Recall          bRxCmdEcho      ;read the Rx echo location\n        Compare\n        GoIfNZ          tsk_SCH_AckWait ; g\/ different\n        SetS            sSCH_GotEcho    ;Signal that the echo is received\n        KillTask                        ;Job done!<\/pre>\n\n\n\n<p>This task just sits looping until the echo matches what was sent, then sets the semaphore and kills itself.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>You need to understand both MultiTrack and SPLat semaphores to understand the following. Down in the core of the program is a mechanism for setting&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":3387,"menu_order":1,"template":"","class_list":["post-3390","spl_knowledgebase","type-spl_knowledgebase","status-publish","hentry"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v25.6 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Setting the command byte, waiting for an echo - SPLat Controls<\/title>\n<meta name=\"robots\" content=\"noindex, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Setting the command byte, waiting for an echo - SPLat Controls\" \/>\n<meta property=\"og:description\" content=\"You need to understand both MultiTrack and SPLat semaphores to understand the following. Down in the core of the program is a mechanism for setting...\" \/>\n<meta property=\"og:url\" content=\"https:\/\/webprojects.cloud\/wordpress\/splatco\/knowledgebase\/tutorials-application-notes-and-white-papers\/tutorial-splat-call-home-sx10509-programming\/example-splat-call-home-sandbox-program\/setting-the-command-byte-waiting-for-an-echo\/\" \/>\n<meta property=\"og:site_name\" content=\"SPLat Controls\" \/>\n<meta property=\"article:modified_time\" content=\"2025-06-10T11:04:03+00:00\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/webprojects.cloud\/wordpress\/splatco\/knowledgebase\/tutorials-application-notes-and-white-papers\/tutorial-splat-call-home-sx10509-programming\/example-splat-call-home-sandbox-program\/setting-the-command-byte-waiting-for-an-echo\/\",\"url\":\"https:\/\/webprojects.cloud\/wordpress\/splatco\/knowledgebase\/tutorials-application-notes-and-white-papers\/tutorial-splat-call-home-sx10509-programming\/example-splat-call-home-sandbox-program\/setting-the-command-byte-waiting-for-an-echo\/\",\"name\":\"Setting the command byte, waiting for an echo - SPLat Controls\",\"isPartOf\":{\"@id\":\"https:\/\/webprojects.cloud\/wordpress\/splatco\/#website\"},\"datePublished\":\"2025-04-18T06:29:48+00:00\",\"dateModified\":\"2025-06-10T11:04:03+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/webprojects.cloud\/wordpress\/splatco\/knowledgebase\/tutorials-application-notes-and-white-papers\/tutorial-splat-call-home-sx10509-programming\/example-splat-call-home-sandbox-program\/setting-the-command-byte-waiting-for-an-echo\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/webprojects.cloud\/wordpress\/splatco\/knowledgebase\/tutorials-application-notes-and-white-papers\/tutorial-splat-call-home-sx10509-programming\/example-splat-call-home-sandbox-program\/setting-the-command-byte-waiting-for-an-echo\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/webprojects.cloud\/wordpress\/splatco\/knowledgebase\/tutorials-application-notes-and-white-papers\/tutorial-splat-call-home-sx10509-programming\/example-splat-call-home-sandbox-program\/setting-the-command-byte-waiting-for-an-echo\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/webprojects.cloud\/wordpress\/splatco\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Tutorials, application notes and white papers\",\"item\":\"https:\/\/webprojects.cloud\/wordpress\/splatco\/knowledgebase\/tutorials-application-notes-and-white-papers\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Tutorial: SPLat Call Home (SX10509) programming\",\"item\":\"https:\/\/webprojects.cloud\/wordpress\/splatco\/knowledgebase\/tutorials-application-notes-and-white-papers\/tutorial-splat-call-home-sx10509-programming\/\"},{\"@type\":\"ListItem\",\"position\":4,\"name\":\"Example: SPLat Call Home sandbox program\",\"item\":\"https:\/\/webprojects.cloud\/wordpress\/splatco\/knowledgebase\/tutorials-application-notes-and-white-papers\/tutorial-splat-call-home-sx10509-programming\/example-splat-call-home-sandbox-program\/\"},{\"@type\":\"ListItem\",\"position\":5,\"name\":\"Setting the command byte, waiting for an echo\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/webprojects.cloud\/wordpress\/splatco\/#website\",\"url\":\"https:\/\/webprojects.cloud\/wordpress\/splatco\/\",\"name\":\"SPLat Controls\",\"description\":\"OEM Embedded Machine Controllers\",\"publisher\":{\"@id\":\"https:\/\/webprojects.cloud\/wordpress\/splatco\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/webprojects.cloud\/wordpress\/splatco\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/webprojects.cloud\/wordpress\/splatco\/#organization\",\"name\":\"SPLat Controls\",\"url\":\"https:\/\/webprojects.cloud\/wordpress\/splatco\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/webprojects.cloud\/wordpress\/splatco\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/webprojects.cloud\/wordpress\/splatco\/wp-content\/uploads\/2024\/10\/logo.svg\",\"contentUrl\":\"https:\/\/webprojects.cloud\/wordpress\/splatco\/wp-content\/uploads\/2024\/10\/logo.svg\",\"caption\":\"SPLat Controls\"},\"image\":{\"@id\":\"https:\/\/webprojects.cloud\/wordpress\/splatco\/#\/schema\/logo\/image\/\"}}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Setting the command byte, waiting for an echo - SPLat Controls","robots":{"index":"noindex","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"og_locale":"en_US","og_type":"article","og_title":"Setting the command byte, waiting for an echo - SPLat Controls","og_description":"You need to understand both MultiTrack and SPLat semaphores to understand the following. Down in the core of the program is a mechanism for setting...","og_url":"https:\/\/webprojects.cloud\/wordpress\/splatco\/knowledgebase\/tutorials-application-notes-and-white-papers\/tutorial-splat-call-home-sx10509-programming\/example-splat-call-home-sandbox-program\/setting-the-command-byte-waiting-for-an-echo\/","og_site_name":"SPLat Controls","article_modified_time":"2025-06-10T11:04:03+00:00","twitter_card":"summary_large_image","twitter_misc":{"Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/webprojects.cloud\/wordpress\/splatco\/knowledgebase\/tutorials-application-notes-and-white-papers\/tutorial-splat-call-home-sx10509-programming\/example-splat-call-home-sandbox-program\/setting-the-command-byte-waiting-for-an-echo\/","url":"https:\/\/webprojects.cloud\/wordpress\/splatco\/knowledgebase\/tutorials-application-notes-and-white-papers\/tutorial-splat-call-home-sx10509-programming\/example-splat-call-home-sandbox-program\/setting-the-command-byte-waiting-for-an-echo\/","name":"Setting the command byte, waiting for an echo - SPLat Controls","isPartOf":{"@id":"https:\/\/webprojects.cloud\/wordpress\/splatco\/#website"},"datePublished":"2025-04-18T06:29:48+00:00","dateModified":"2025-06-10T11:04:03+00:00","breadcrumb":{"@id":"https:\/\/webprojects.cloud\/wordpress\/splatco\/knowledgebase\/tutorials-application-notes-and-white-papers\/tutorial-splat-call-home-sx10509-programming\/example-splat-call-home-sandbox-program\/setting-the-command-byte-waiting-for-an-echo\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/webprojects.cloud\/wordpress\/splatco\/knowledgebase\/tutorials-application-notes-and-white-papers\/tutorial-splat-call-home-sx10509-programming\/example-splat-call-home-sandbox-program\/setting-the-command-byte-waiting-for-an-echo\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/webprojects.cloud\/wordpress\/splatco\/knowledgebase\/tutorials-application-notes-and-white-papers\/tutorial-splat-call-home-sx10509-programming\/example-splat-call-home-sandbox-program\/setting-the-command-byte-waiting-for-an-echo\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/webprojects.cloud\/wordpress\/splatco\/"},{"@type":"ListItem","position":2,"name":"Tutorials, application notes and white papers","item":"https:\/\/webprojects.cloud\/wordpress\/splatco\/knowledgebase\/tutorials-application-notes-and-white-papers\/"},{"@type":"ListItem","position":3,"name":"Tutorial: SPLat Call Home (SX10509) programming","item":"https:\/\/webprojects.cloud\/wordpress\/splatco\/knowledgebase\/tutorials-application-notes-and-white-papers\/tutorial-splat-call-home-sx10509-programming\/"},{"@type":"ListItem","position":4,"name":"Example: SPLat Call Home sandbox program","item":"https:\/\/webprojects.cloud\/wordpress\/splatco\/knowledgebase\/tutorials-application-notes-and-white-papers\/tutorial-splat-call-home-sx10509-programming\/example-splat-call-home-sandbox-program\/"},{"@type":"ListItem","position":5,"name":"Setting the command byte, waiting for an echo"}]},{"@type":"WebSite","@id":"https:\/\/webprojects.cloud\/wordpress\/splatco\/#website","url":"https:\/\/webprojects.cloud\/wordpress\/splatco\/","name":"SPLat Controls","description":"OEM Embedded Machine Controllers","publisher":{"@id":"https:\/\/webprojects.cloud\/wordpress\/splatco\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/webprojects.cloud\/wordpress\/splatco\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/webprojects.cloud\/wordpress\/splatco\/#organization","name":"SPLat Controls","url":"https:\/\/webprojects.cloud\/wordpress\/splatco\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/webprojects.cloud\/wordpress\/splatco\/#\/schema\/logo\/image\/","url":"https:\/\/webprojects.cloud\/wordpress\/splatco\/wp-content\/uploads\/2024\/10\/logo.svg","contentUrl":"https:\/\/webprojects.cloud\/wordpress\/splatco\/wp-content\/uploads\/2024\/10\/logo.svg","caption":"SPLat Controls"},"image":{"@id":"https:\/\/webprojects.cloud\/wordpress\/splatco\/#\/schema\/logo\/image\/"}}]}},"_links":{"self":[{"href":"https:\/\/webprojects.cloud\/wordpress\/splatco\/wp-json\/wp\/v2\/spl_knowledgebase\/3390","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/webprojects.cloud\/wordpress\/splatco\/wp-json\/wp\/v2\/spl_knowledgebase"}],"about":[{"href":"https:\/\/webprojects.cloud\/wordpress\/splatco\/wp-json\/wp\/v2\/types\/spl_knowledgebase"}],"author":[{"embeddable":true,"href":"https:\/\/webprojects.cloud\/wordpress\/splatco\/wp-json\/wp\/v2\/users\/1"}],"up":[{"embeddable":true,"href":"https:\/\/webprojects.cloud\/wordpress\/splatco\/wp-json\/wp\/v2\/spl_knowledgebase\/3387"}],"wp:attachment":[{"href":"https:\/\/webprojects.cloud\/wordpress\/splatco\/wp-json\/wp\/v2\/media?parent=3390"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}