{"id":48,"date":"2017-03-19T20:44:30","date_gmt":"2017-03-20T03:44:30","guid":{"rendered":"https:\/\/sysprogs.com\/tutorials\/?p=48"},"modified":"2018-04-25T13:55:45","modified_gmt":"2018-04-25T20:55:45","slug":"capturing-continuous-data-streams","status":"publish","type":"post","link":"https:\/\/sysprogs.com\/analyzer2go\/tutorials\/continuous\/","title":{"rendered":"Capturing Continuous Data Streams"},"content":{"rendered":"<p>This tutorial shows how to use Analyzer2Go to capture data continuously. This mode is used to capture large portions of data non-stop and then analyze and annotate them. Before you begin, follow the <a href=\"https:\/\/sysprogs.com\/analyzer2go\/tutorials\/signals\/\">basic Analyzer2Go tutorial<\/a> to get the basics running.<\/p>\n<p>In this tutorial we will use one STM32F4Discovery board to generate signals showing the timings of the interrupt handlers and another STM32F4Discovery board controlled by Analyzer2Go will be used to capture those signals.<\/p>\n<p>Compile and download the following program into the generator board:<\/p>\n<pre class=\"\">static TIM_HandleTypeDef s_Timer = { \r\n\u00a0\u00a0 \u00a0.Instance = TIM4\r\n};\r\n\r\nvoid SysTick_Handler(void)\r\n{\r\n\u00a0\u00a0 \u00a0HAL_GPIO_WritePin(GPIOD, GPIO_PIN_14, GPIO_PIN_SET);\r\n\u00a0\u00a0 \u00a0HAL_IncTick();\r\n\u00a0\u00a0 \u00a0HAL_SYSTICK_IRQHandler();\r\n\u00a0\u00a0 \u00a0HAL_GPIO_WritePin(GPIOD, GPIO_PIN_14, GPIO_PIN_RESET);\r\n}\r\n\r\nextern \"C\" void TIM4_IRQHandler()\r\n{\r\n\u00a0\u00a0 \u00a0HAL_GPIO_WritePin(GPIOD, GPIO_PIN_13, GPIO_PIN_SET);\r\n\u00a0\u00a0 \u00a0HAL_TIM_IRQHandler(&amp;s_Timer);\r\n\u00a0\u00a0 \u00a0HAL_GPIO_WritePin(GPIOD, GPIO_PIN_13, GPIO_PIN_RESET);\r\n}\r\n\r\nvoid DemonstrateInterrupts()\r\n{\r\n\u00a0\u00a0 \u00a0int prescaler = 16;\r\n\u00a0\u00a0 \u00a0int period = 999;\r\n\u00a0\u00a0 \u00a0\r\n\u00a0\u00a0 \u00a0__TIM4_CLK_ENABLE();\r\n\u00a0\u00a0 \u00a0s_Timer.Init.Prescaler = prescaler - 1;\r\n\u00a0\u00a0 \u00a0s_Timer.Init.CounterMode = TIM_COUNTERMODE_UP;\r\n\u00a0\u00a0 \u00a0s_Timer.Init.Period = period - 1;\r\n\u00a0\u00a0 \u00a0s_Timer.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1;\r\n\u00a0\u00a0 \u00a0s_Timer.Init.RepetitionCounter = 0;\r\n\u00a0\u00a0 \u00a0\r\n\u00a0\u00a0 \u00a0if (HAL_TIM_Base_Init(&amp;s_Timer) != HAL_OK)\r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0asm(\"bkpt 255\");\r\n\u00a0\u00a0 \u00a0if (HAL_TIM_Base_Start_IT(&amp;s_Timer) != HAL_OK)\r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0asm(\"bkpt 255\");\r\n\u00a0\u00a0 \u00a0__HAL_TIM_ENABLE_IT(&amp;s_Timer, TIM_IT_UPDATE);\r\n\u00a0\u00a0 \u00a0NVIC_EnableIRQ(TIM4_IRQn);\r\n\u00a0\u00a0 \u00a0\r\n\u00a0\u00a0 \u00a0__GPIOD_CLK_ENABLE();\r\n\u00a0\u00a0 \u00a0GPIO_InitTypeDef GPIO_InitStructure;\r\n\r\n\u00a0\u00a0 \u00a0GPIO_InitStructure.Pin = GPIO_PIN_12 | GPIO_PIN_13 | GPIO_PIN_14;\r\n\r\n\u00a0\u00a0 \u00a0GPIO_InitStructure.Mode = GPIO_MODE_OUTPUT_PP;\r\n\u00a0\u00a0 \u00a0GPIO_InitStructure.Speed = GPIO_SPEED_HIGH;\r\n\u00a0\u00a0 \u00a0GPIO_InitStructure.Pull = GPIO_NOPULL;\r\n\u00a0\u00a0 \u00a0GPIO_InitStructure.Alternate = GPIO_AF2_TIM4;\r\n\u00a0\u00a0 \u00a0HAL_GPIO_Init(GPIOD, &amp;GPIO_InitStructure);\r\n}<\/pre>\n<p>As the continuous mode uses lower sampling frequencies than the regular frame-by-frame mode, ensure that the board generating signals is running at a reduced frequency (the default frequency after reset is usually slow enough). If you are using a different board, specify the timer period and prescaler that makes the timer frequency very close to the SysTick period.<\/p>\n<ol>\n<li>Start Analyzer2Go and connect the input pins of the board used as a logic analyzer to the PB13 and PB14 channels that will show the interrupt timings on the first board. You will see that the timer interrupt and the SysTick interrupt occur at roughly the same frequency:<img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-49\" src=\"https:\/\/sysprogs.com\/tutorials\/wp-content\/uploads\/2017\/03\/01-2events.png\" alt=\"\" width=\"1026\" height=\"752\" srcset=\"https:\/\/sysprogs.com\/tutorials\/wp-content\/uploads\/2017\/03\/01-2events.png 1026w, https:\/\/sysprogs.com\/tutorials\/wp-content\/uploads\/2017\/03\/01-2events-300x220.png 300w, https:\/\/sysprogs.com\/tutorials\/wp-content\/uploads\/2017\/03\/01-2events-768x563.png 768w, https:\/\/sysprogs.com\/tutorials\/wp-content\/uploads\/2017\/03\/01-2events-1024x751.png 1024w\" sizes=\"(max-width: 1026px) 100vw, 1026px\" \/><\/li>\n<li>We will use Analyzer2Go to see what happens when both interrupts coincide. As that event happens relatively rarely, the chance that it will fit into a random frame is very low, so we will use the continuous capture mode to capture several seconds of measurements non-stop. Click the &#8220;Record&#8221; button. Analyzer2Go will ask you to connect the second USB connector to get the maximum transfer speed:<img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-50\" src=\"https:\/\/sysprogs.com\/tutorials\/wp-content\/uploads\/2017\/03\/02-auxconn.png\" alt=\"\" width=\"649\" height=\"458\" srcset=\"https:\/\/sysprogs.com\/tutorials\/wp-content\/uploads\/2017\/03\/02-auxconn.png 649w, https:\/\/sysprogs.com\/tutorials\/wp-content\/uploads\/2017\/03\/02-auxconn-300x212.png 300w\" sizes=\"(max-width: 649px) 100vw, 649px\" \/><\/li>\n<li>After you plug in the second connector, Analyzer2Go will begin sampling the data. You can zoom and view the captured data while it is being captured, or simply stop it after several seconds:<img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-51\" src=\"https:\/\/sysprogs.com\/tutorials\/wp-content\/uploads\/2017\/03\/03-continuous.png\" alt=\"\" width=\"1103\" height=\"823\" srcset=\"https:\/\/sysprogs.com\/tutorials\/wp-content\/uploads\/2017\/03\/03-continuous.png 1103w, https:\/\/sysprogs.com\/tutorials\/wp-content\/uploads\/2017\/03\/03-continuous-300x224.png 300w, https:\/\/sysprogs.com\/tutorials\/wp-content\/uploads\/2017\/03\/03-continuous-768x573.png 768w, https:\/\/sysprogs.com\/tutorials\/wp-content\/uploads\/2017\/03\/03-continuous-1024x764.png 1024w\" sizes=\"(max-width: 1103px) 100vw, 1103px\" \/><\/li>\n<li>Double-click on any of the signals to zoom to a meaningful scale. Then use the &#8220;previous event&#8221; and &#8220;next event&#8221; buttons to navigate to a point where the 2 interrupts happen close to each other:<img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-52\" src=\"https:\/\/sysprogs.com\/tutorials\/wp-content\/uploads\/2017\/03\/04-events.png\" alt=\"\" width=\"1026\" height=\"752\" srcset=\"https:\/\/sysprogs.com\/tutorials\/wp-content\/uploads\/2017\/03\/04-events.png 1026w, https:\/\/sysprogs.com\/tutorials\/wp-content\/uploads\/2017\/03\/04-events-300x220.png 300w, https:\/\/sysprogs.com\/tutorials\/wp-content\/uploads\/2017\/03\/04-events-768x563.png 768w, https:\/\/sysprogs.com\/tutorials\/wp-content\/uploads\/2017\/03\/04-events-1024x751.png 1024w\" sizes=\"(max-width: 1026px) 100vw, 1026px\" \/><\/li>\n<li>Once you locate that point, you can add a note to it using the &#8220;notes bar&#8221;. The note can be used later to quickly jump to that part of the capture file: <img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-54\" src=\"https:\/\/sysprogs.com\/tutorials\/wp-content\/uploads\/2017\/03\/06-coincided.png\" alt=\"\" width=\"1026\" height=\"752\" srcset=\"https:\/\/sysprogs.com\/tutorials\/wp-content\/uploads\/2017\/03\/06-coincided.png 1026w, https:\/\/sysprogs.com\/tutorials\/wp-content\/uploads\/2017\/03\/06-coincided-300x220.png 300w, https:\/\/sysprogs.com\/tutorials\/wp-content\/uploads\/2017\/03\/06-coincided-768x563.png 768w, https:\/\/sysprogs.com\/tutorials\/wp-content\/uploads\/2017\/03\/06-coincided-1024x751.png 1024w\" sizes=\"(max-width: 1026px) 100vw, 1026px\" \/>The captured data shows that the SysTick interrupt (green) is preempted by the TIM4 Interrupt (blue). I.e. if the TIM4 interrupt happens while the SysTick interrupt handler was already running, the SysTick interrupt handler will be invoked on top of it. Use the &#8220;Save button&#8221; to save the captured data (and the note) for further comparison.<\/li>\n<li>Add the following code to the program to assigned higher priority to the TIM4 interrupt so that it won&#8217;t get preempted by SysTick:\n<pre class=\"\">\u00a0\u00a0\u00a0 NVIC_SetPriority(TIM4_IRQn, 1);\r\n\u00a0\u00a0 \u00a0NVIC_SetPriority(SysTick_IRQn, 0);<\/pre>\n<\/li>\n<li>Run another round of continuous capture to record the new timings and navigate to the point in time where the interrupts coincide. See how the SysTick interrupt (green) is now never preempted by the TIM4 interrupt (blue):<img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-55\" src=\"https:\/\/sysprogs.com\/tutorials\/wp-content\/uploads\/2017\/03\/07-otherway.png\" alt=\"\" width=\"1026\" height=\"752\" srcset=\"https:\/\/sysprogs.com\/tutorials\/wp-content\/uploads\/2017\/03\/07-otherway.png 1026w, https:\/\/sysprogs.com\/tutorials\/wp-content\/uploads\/2017\/03\/07-otherway-300x220.png 300w, https:\/\/sysprogs.com\/tutorials\/wp-content\/uploads\/2017\/03\/07-otherway-768x563.png 768w, https:\/\/sysprogs.com\/tutorials\/wp-content\/uploads\/2017\/03\/07-otherway-1024x751.png 1024w\" sizes=\"(max-width: 1026px) 100vw, 1026px\" \/><\/li>\n<li>You can switch back to the tab with the saved file to compare how the signals looked before and after. If you scroll out of the area where the interrupts coincided, use the &#8220;Notes&#8221; bar to quickly navigate back to it:<img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-56\" src=\"https:\/\/sysprogs.com\/tutorials\/wp-content\/uploads\/2017\/03\/08-goto.png\" alt=\"\" width=\"1026\" height=\"752\" srcset=\"https:\/\/sysprogs.com\/tutorials\/wp-content\/uploads\/2017\/03\/08-goto.png 1026w, https:\/\/sysprogs.com\/tutorials\/wp-content\/uploads\/2017\/03\/08-goto-300x220.png 300w, https:\/\/sysprogs.com\/tutorials\/wp-content\/uploads\/2017\/03\/08-goto-768x563.png 768w, https:\/\/sysprogs.com\/tutorials\/wp-content\/uploads\/2017\/03\/08-goto-1024x751.png 1024w\" sizes=\"(max-width: 1026px) 100vw, 1026px\" \/><\/li>\n<\/ol>\n<p>Starting from\u00a0version 2.0 Analyzer2Go is compatible with the Cypress\u00a0SuperSpeed Explorer Kit, supporting\u00a0continuous\u00a0capture at 200MHz\u00a0via the fast USB 3.0 interface. Check out\u00a0the\u00a0<a href=\"https:\/\/sysprogs.com\/analyzer2go\/tutorials\/superspeed\/\">SuperSpeed tutorial<\/a>\u00a0for details.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>This tutorial shows how to use Analyzer2Go to capture data continuously. This mode is used to capture large portions of<\/p>\n","protected":false},"author":1,"featured_media":57,"comment_status":"closed","ping_status":"closed","sticky":true,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[14,15],"_links":{"self":[{"href":"https:\/\/sysprogs.com\/tutorials\/wp-json\/wp\/v2\/posts\/48"}],"collection":[{"href":"https:\/\/sysprogs.com\/tutorials\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/sysprogs.com\/tutorials\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/sysprogs.com\/tutorials\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/sysprogs.com\/tutorials\/wp-json\/wp\/v2\/comments?post=48"}],"version-history":[{"count":2,"href":"https:\/\/sysprogs.com\/tutorials\/wp-json\/wp\/v2\/posts\/48\/revisions"}],"predecessor-version":[{"id":302,"href":"https:\/\/sysprogs.com\/tutorials\/wp-json\/wp\/v2\/posts\/48\/revisions\/302"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/sysprogs.com\/tutorials\/wp-json\/wp\/v2\/media\/57"}],"wp:attachment":[{"href":"https:\/\/sysprogs.com\/tutorials\/wp-json\/wp\/v2\/media?parent=48"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/sysprogs.com\/tutorials\/wp-json\/wp\/v2\/categories?post=48"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/sysprogs.com\/tutorials\/wp-json\/wp\/v2\/tags?post=48"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}