avr-gcc-list
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[avr-gcc-list] Xmega support


From: Parthasaradhi Nayani
Subject: [avr-gcc-list] Xmega support
Date: Wed, 19 Aug 2009 04:02:54 -0700 (PDT)

Hello all,
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

char globalbuf[20];

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.

Regards
Nayani P











reply via email to

[Prev in Thread] Current Thread [Next in Thread]