Studio 4 won't simulate the atxmega32a4 so I am giving Studio 5 a try. I had been using Hapsim for serial output but that does not work with Studio 5 (yet?).
I changed the rs232_send routine to place strings in RAM instead of using the uart hardware:
void rs232_send(uint8_t port, unsigned char c) { #define SIMULATING 1 #if SIMULATING //for AVR studio simulator static char rs232output [RS232_COUNT][32]; static uint8_t rs232pos; rs232output[port][rs232pos++]=c; if ((c=='\n')||(rs232pos>=32)) { for (;rs232pos<32;) rs232output[port][rs232pos++]=0; asm volatile("break"); rs232pos=0; } #else rs232_ports[port].txwait = 1; *(rs232_ports[port].DATA) = c; while(rs232_ports[port].txwait); #endif }
When the break is executed the first time, mouseover the rs323output symbol to get the address and display that in a memory window, sizing it so the strings from each port line up. From then on just hit continue and it will stop on each output string (if it ends in 0x0a, else when the buffer is full).
For testing in the main routine, e.g.
extern uint8_t stdout_rs232_port; {int i;for (i=0;i
Note on the attached screen dump that even though the routine is called with port = 2, the value at the break is shown to be 0x15! Don't know if this can be considered a bug; Studio displays the value of R24 for it even after R24 has been reused for the rs232pos increment.