|This message got buried in a thread, because you used a reply to a previous message from the list.|
It's poor manners to hijack threads, and can cause some users not to reply.
not much in terms of help though, writing up a quick, complete test case may help us help you.
is globalbuf accessed anywhere in the ISR functions??
On Aug 19, 2009, at 4:02 AM, Parthasaradhi Nayani wrote:
I have just started testing an XMEGA64 chip and I find a peculiar problem when I use sprintf. Following are the environment/specs:
XMEGA64 running at 32MHz (using the internal freq generator)
USART on PC0, operating at 115K BAUD.
One timer in port D being used in compare capture mode.
The program is a very simple one. At start, 8000H, (let me call this CCAVAL) is written into the compare register and this generates a frequency on pin OC0A. Usart receive is interrupt driven. When a new value for CCAVAL is sent through the serial port, main loop converts the value and writes to the compare register. This should change the frequency of the square wave on OC0A. To test the vaule being written to ccaval is being sent back to PC and this is where the peculiar problem is noticed. We are using sprintf function to conver the binary value of ccaval and then sending it PC through another function. When
we use a global buffer in sprintf, the program behaves erratically. The timer stops for some time and then starts with the new value. However if use a local buffer in sprintf then everything works fine. Example code given below
sprintf (globalbuf,"%05u\r\n",ccaval); // problem. globalbuf defined outside main.
sprintf (localbuf,"%05u\r\n", ccaval); // no problem. everything works fine.
Can some one point me to the mistake we are making? or is this a problem with GCC? Thank you.
AVR-GCC-list mailing list