Thank you for commenting on this. Its very appreciated.
<div class='quotetop'>QUOTE </div>
--- Quote Start ---
Thanks for doing a lot of the work tracking down a minimum case where it stops working. Does this same code work in a HAL only project?[/b]
--- Quote End ---
Yes, no problems in HAL mode.
<div class='quotetop'>QUOTE </div>
--- Quote Start ---
Does it work if you step over the printf lots of times rather than letting it run?[/b]
--- Quote End ---
Yes then it works, but for debugger not to get absorbed in the printf statement, i had to modify the code slightly to be covered by two lines
#include <stdio.h>
int main()
{
int i=0;
while(1) {
printf("%1d",i % 10);
i++;}
//.. this hangs after 91 to 93 characters if free running
// if debugged line by line, it works for as long as I had patience (>150)
return 0;
}
It still fails in debug single state-mode if I print a long line with more than 93 chars in one printf statement like
printf("Looooooooooooooooooooooooooooooooooooooooooong line >93 chars");
<div class='quotetop'>QUOTE </div>
--- Quote Start ---
Where it the processor stuck if you press pause in the debugger?[/b]
--- Quote End ---
Varies (ofcourse): Sometime in OsCore.c as
for (;;) {
OS_ENTER_CRITICAL();
OSIdleCtr++;
OS_EXIT_CRITICAL();# if OS_CPU_HOOKS_EN
OSTaskIdleHook(); /* Call user definable HOOK */# endif
Some times its in alt_irq.c caught doing
static ALT_INLINE alt_irq_context ALT_ALWAYS_INLINE
alt_irq_disable_all (void)
{
alt_irq_context context;
NIOS2_READ_STATUS (context);
NIOS2_WRITE_STATUS (0);
return context;
}
static ALT_INLINE void ALT_ALWAYS_INLINE
alt_irq_enable_all (alt_irq_context context)
{
NIOS2_WRITE_STATUS (context);
}
Stepping down into the code is very confusing, at least to me, it jumps in an unexpected manner. Maybe its the macros which plays me a trick or maybe the interrupts. Anyway it seems to always spin in the same track of this for(;;) loop.
<div class='quotetop'>QUOTE </div>
--- Quote Start ---
I wonder whether this is something to do with event flags. When the UART driver's buffer fills up it waits on an event (ALT_FLAG_PEND in altera_avalon_uart.c).[/b]
--- Quote End ---
I never caught it down in altera_avalon_uart.c
<div class='quotetop'>QUOTE </div>
--- Quote Start ---
In the uCOS-II case this uses the event flag mechanism built into the OS. But you haven't started the OS yet (by calling OSStart) so the event flags may not work correctly (I haven't looked at the code yet).[/b]
--- Quote End ---
I tried using tasks also. In fact that was where I came from before stripping the code to minimum. If I call OSStart() The tasks start and run correctly. I never get past OSStart() so putting printf's here will never get called, unless maybe all my tasks stops, but thats not what I wanted. Putting printf() before breaks as described above. My last option is to create a task for printing my message. Thanks for reading this far. Comments welcome.