<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><br class=""><div class=""><blockquote type="cite" class=""><div class="">On 2015-June-13, at 8:50 AM, Sebastian Huber <<a href="mailto:sebastian.huber@embedded-brains.de" class="">sebastian.huber@embedded-brains.de</a>> wrote:</div><br class="Apple-interchange-newline"><div class="">Halloo Andrei,<br class=""><br class="">I checked in a patch that hopefully helps to debug this problem. Please update the RTEMS sources and build the BSP with the --enable-rtems-debug configure option. This will define RTEMS_DEBUG and enables a lot of assertions that detect incorrect states in the operating system. Set a break point to __assert_func(). In case you hit this break point, then it would be helpful to send the stack trace to the mailing list.<br class=""></div></blockquote><br class=""></div><div class="">V-gates Sebastian (wie geitz),</div><div class=""><br class=""></div><div class=""><br class=""></div><div class="">I did a git pull and rebuild and the results ARE different, and interesting I believe.</div><div class=""><br class=""></div><div class="">I’m still working on a striped down version of the program but it looks to be an interrupt related issue, so I’ll give you an idea of what is going on here.</div><div class=""><br class=""></div><div class="">I hook the ADC DMA half and full transfer complete interrupts using:</div><div class=""><br class=""></div><div class=""><div style="margin: 0px; font-family: 'Courier New';" class=""><span class="Apple-tab-span" style="white-space:pre"> </span>status = <span style="color: #793d93" class=""><b class="">rtems_interrupt_handler_install</b></span>((<span style="color: #006141" class="">rtems_vector_number</span>) <span style="text-decoration: underline" class="">DMA2_Stream0_IRQn</span>,</div><div style="margin: 0px; font-family: 'Courier New';" class=""><span class="Apple-tab-span" style="white-space:pre"> </span>ADC1handlerName, RTEMS_INTERRUPT_UNIQUE,</div><div style="margin: 0px; font-family: 'Courier New';" class=""><span class="Apple-tab-span" style="white-space:pre"> </span>(<span style="color: #006141" class="">rtems_interrupt_handler</span>) DMA2_Stream0_IRQHandler, NULL);</div><div style="margin: 0px; font-family: 'Courier New';" class=""><span class="Apple-tab-span" style="white-space:pre"> </span><span style="color: #931a68" class=""><b class="">if</b></span> (status != <span style="color: #0326cc" class=""><i class="">RTEMS_SUCCESSFUL</i></span>) {</div><div style="margin: 0px; font-family: 'Courier New'; color: rgb(57, 51, 255);" class=""><span style="color: #000000" class=""><span class="Apple-tab-span" style="white-space:pre"> </span></span><span style="color: #793d93" class=""><b class="">printk</b></span><span style="color: #000000" class="">(</span>"interrupt handler install 1 failed with %d\n"<span style="color: #000000" class="">, status);</span></div><div style="margin: 0px; font-family: 'Courier New';" class=""><span class="Apple-tab-span" style="white-space:pre"> </span>}</div><div style="margin: 0px; font-family: 'Courier New'; min-height: 14px;" class=""><br class=""></div><div style="margin: 0px; font-family: 'Courier New';" class=""><span class="Apple-tab-span" style="white-space:pre"> </span>status = <span style="color: #793d93" class=""><b class="">rtems_interrupt_handler_install</b></span>((<span style="color: #006141" class="">rtems_vector_number</span>) <span style="text-decoration: underline" class="">DMA2_Stream2_IRQn</span>,</div><div style="margin: 0px; font-family: 'Courier New';" class=""><span class="Apple-tab-span" style="white-space:pre"> </span>ADC2handlerName, RTEMS_INTERRUPT_UNIQUE,</div><div style="margin: 0px; font-family: 'Courier New';" class=""><span class="Apple-tab-span" style="white-space:pre"> </span>(<span style="color: #006141" class="">rtems_interrupt_handler</span>) DMA2_Stream2_IRQHandler, NULL);</div><div style="margin: 0px; font-family: 'Courier New';" class=""><span class="Apple-tab-span" style="white-space:pre"> </span><span style="color: #931a68" class=""><b class="">if</b></span> (status != <span style="color: #0326cc" class=""><i class="">RTEMS_SUCCESSFUL</i></span>) {</div><div style="margin: 0px; font-family: 'Courier New'; color: rgb(57, 51, 255);" class=""><span style="color: #000000" class=""><span class="Apple-tab-span" style="white-space:pre"> </span></span><span style="color: #793d93" class=""><b class="">printk</b></span><span style="color: #000000" class="">(</span>"interrupt handler install 2 failed with %d\n"<span style="color: #000000" class="">, status);</span></div><div style="margin: 0px; font-family: 'Courier New';" class=""><span class="Apple-tab-span" style="white-space:pre"> </span>}</div><div style="margin: 0px; font-family: 'Courier New'; min-height: 14px;" class=""><br class=""></div><div style="margin: 0px; font-family: 'Courier New'; min-height: 14px;" class=""><br class=""></div><div style="margin: 0px; font-family: 'Courier New'; min-height: 14px;" class=""><span style="font-family: Sabon;" class="">From the traceback, the half complete callback (DMA2_Stream0_IRQHandler, supplied by ST as a part of the CubeMX HAL, calls HAL_DMA_IRQHandler which figures out the reason for the interrupt and calls HAL_ADC_ConvHalfCpltCallback) which:</span></div><div style="margin: 0px; font-family: 'Courier New'; min-height: 14px;" class=""><span style="font-family: Sabon;" class=""><br class=""></span></div><div style="margin: 0px; font-family: 'Courier New'; min-height: 14px;" class=""><div style="margin: 0px;" class=""><span style="color: #931a68" class=""><b class="">void</b></span> <b class="">HAL_ADC_ConvHalfCpltCallback</b>(<span style="color: #006141" class="">ADC_HandleTypeDef</span>* hadc) {</div><div style="margin: 0px; color: rgb(3, 38, 204);" class=""><span style="color: #000000" class=""><span class="Apple-tab-span" style="white-space:pre"> </span>LEDOff(</span><i class="">LED_NAMES_RED</i><span style="color: #000000" class="">);</span></div><div style="margin: 0px; color: rgb(0, 97, 65);" class=""><span style="color: #000000" class=""><span class="Apple-tab-span" style="white-space:pre"> </span></span>rtems_status_code<span style="color: #000000" class=""> status;</span></div><div style="margin: 0px;" class=""><span class="Apple-tab-span" style="white-space:pre"> </span>status = <span style="color: #793d93" class=""><b class="">rtems_event_send</b></span>( ADCTaskId, RTEMS_EVENT_1);</div><div style="margin: 0px;" class=""><span class="Apple-tab-span" style="white-space:pre"> </span><span style="color: #931a68" class=""><b class="">if</b></span> (status != <span style="color: #0326cc" class=""><i class="">RTEMS_SUCCESSFUL</i></span>) {</div><div style="margin: 0px; color: rgb(57, 51, 255);" class=""><span style="color: #000000" class=""><span class="Apple-tab-span" style="white-space:pre"> </span></span><span style="color: #793d93" class=""><b class="">printk</b></span><span style="color: #000000" class="">(</span>"half complete callback failed with %d"<span style="color: #000000" class="">,status);</span></div><div style="margin: 0px;" class=""><span class="Apple-tab-span" style="white-space:pre"> </span>}</div><div style="margin: 0px;" class="">}</div><div class=""><br class=""></div></div></div><div class="">Which generates:</div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><br class=""></div><div style="margin: 0px; font-size: 9px; font-family: Monaco;" class="">assertion "_ISR_Get_level() != 0" failed: file "../../cpukit/../../../stm32f4/lib/include/rtems/score/threadimpl.h", line 990, function: _Thread_Lock_acquire_default_critical</div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><div style="margin: 0px; font-size: 11px; font-family: Monaco;" class="">#0 0x0001d57c in _Terminate (the_source=the_source@entry=RTEMS_FATAL_SOURCE_ASSERT, is_internal=is_internal@entry=false, the_error=the_error@entry=536875264) at ../../../../../../rtems/c/src/../../cpukit/score/src/interr.c:52</div><div style="margin: 0px; font-size: 11px; font-family: Monaco;" class="">#1 0x0001c7c6 in rtems_fatal (source=source@entry=RTEMS_FATAL_SOURCE_ASSERT, error=error@entry=536875264) at ../../../../../../rtems/c/src/../../cpukit/sapi/src/fatal2.c:34</div><div style="margin: 0px; font-size: 11px; font-family: Monaco;" class="">#2 0x00018dbc in __assert_func (file=file@entry=0x2423c "../../cpukit/../../../stm32f4/lib/include/rtems/score/threadimpl.h", line=128, line@entry=990, func=func@entry=0x24214 <__FUNCTION__.7604> "_Thread_Lock_acquire_default_critical", failedexpr=failedexpr@entry=0x24280 "_ISR_Get_level() != 0") at ../../../../../../rtems/c/src/../../cpukit/libcsupport/src/__assert.c:52</div><div style="margin: 0px; font-size: 11px; font-family: Monaco;" class="">#3 0x0001bdd2 in _Thread_Lock_acquire_default_critical (the_thread=0x0 <bsp_start_vector_table_begin>, lock_context=0x2000113c, lock_context@entry=0x2000111c) at ../../cpukit/../../../stm32f4/lib/include/rtems/score/threadimpl.h:990</div><div style="margin: 0px; font-size: 11px; font-family: Monaco;" class="">#4 _Event_Surrender (the_thread=0x0 <bsp_start_vector_table_begin>, event_in=event_in@entry=2, event=0x80 <bsp_start_vector_table_begin+128>, wait_class=wait_class@entry=256, lock_context=lock_context@entry=0x2000113c) at ../../../../../../rtems/c/src/../../cpukit/rtems/src/eventsurrender.c:67</div><div style="margin: 0px; font-size: 11px; font-family: Monaco;" class="">#5 0x0001bcf6 in rtems_event_send (id=<optimized out>, event_in=event_in@entry=2) at ../../../../../../rtems/c/src/../../cpukit/rtems/src/eventsend.c:40</div><div style="margin: 0px; font-size: 11px; font-family: Monaco;" class="">#6 0x0000058e in HAL_ADC_ConvHalfCpltCallback (hadc=<optimized out>) at ../src/adctask.c:258</div><div style="margin: 0px; font-size: 11px; font-family: Monaco;" class="">#7 0x00007704 in HAL_DMA_IRQHandler (hdma=0x20002560 <hdma_adc1>) at ../Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_dma.c:763</div><div style="margin: 0px; font-size: 11px; font-family: Monaco;" class="">#8 0x00018766 in bsp_interrupt_handler_dispatch (vector=<optimized out>) at ../../../../../.././stm32f4/lib/include/bsp/irq-generic.h:266</div><div style="margin: 0px; font-size: 11px; font-family: Monaco;" class="">#9 _ARMV7M_NVIC_Interrupt_dispatch () at ../../../../../../../../rtems/c/src/lib/libbsp/arm/stm32f4/../shared/armv7m/irq/armv7m-irq-dispatch.c:28</div><div style="margin: 0px; font-size: 11px; font-family: Monaco;" class="">#10 <signal handler called></div><div style="margin: 0px; font-size: 11px; font-family: Monaco;" class="">#11 0x00000000 in bsp_start_vector_table_begin ()</div></div><div style="margin: 0px; font-size: 11px; font-family: Monaco;" class=""><br class=""></div><div style="margin: 0px; font-size: 11px; font-family: Monaco;" class="">A</div><div style="margin: 0px; font-size: 11px; font-family: Monaco;" class=""><br class=""></div><div style="margin: 0px; font-size: 11px; font-family: Monaco;" class=""><br class=""></div></body></html>