Hi, When I execute the first putchar statement in the code below, nothing is printed to the serial window, when I execute the second putchar statement, the value I thought would print out firstly (0xFF) prints out now. In the for loop I have printed the value i, but likewise the value for i prints out after executing the second putchar statement in that loop. Any ideas why this is happening? Also I have reset the value of counter1 to 2, but as I am stepping through the putchar statements, counter1 increases. I cant see how this can happen as the only way the counter can increment is in the ADC interrupt routine, but the program doesn't jump to this routine in the meantime? If anyone can help, it would be great! Lisa
if(finished) { rec1[buf].cnt = counter1; // store counter1 value in 1st element of array buf ^= 1; // set alternative buffer up counter1 = 2; // reset counter1 to original value // print out whole structure putchar(rec1[!buf].cnt); putchar((char) (rec1[!buf].base_value >> 8)); putchar((char) (rec1[!buf].base_value)); for(i = 0; i < MAX_COUNT-2; i++) { putchar(i); putchar(rec1[!buf].x[i]); } finished = 0; }
Here's a thought. Have you enabled trace in the simulator and set a breakpoint on accesses to counter1. Then, you can review the trace history to see what happened. Jon
There are the following points to note when working with the simulator. 1. Unlike real hardware, the simulator lets you single step even in places where you watch at the timing of peripherals. 2. For infinite printf speed, you may set the SxTIME variable to 0. In this case the simulator does not longer 'simulate' the timing of a serial interface and presents the character on the serial window. This works also for the printf style debugging, that you are trying to perform.