You wrote
>>> eeprom_read_block((void *)&setPgm, (const void *)eepLoc, num) ;
What is num?
-=Dave
From: AVR-GCC-list on behalf
of Royce Pereira
Sent: Tuesday, June 9, 2020 8:18 AM
To: avr-gcc-list@nongnu.org
Subject: Saving & retreiving a structure in eep
> From: graceindustr...@gmail.com
[...]
> So that explains the difference. Seems like there could be a better
> error message for this case, 'don't use enum here', alas "The
> preprocessor does not know anything about types in the language"...
Here's a cute/ugly little macro that might help yo
From: jb@gmx.de:
> I'm trying to do rounded (opposed to truncated) integer division with
> avr-gcc with using only preprocessor magic. This proves to be difficult:
> The current code I'm using is
>
> #define __IDIV(x, y) (long)(((long)x + ((long)y / 2L)) / (long)y)
> #define IDIV(x, y) (__IDI
From: i...@hotmail.com
>That would work. Another way is to have get_key return int.
Oops. I mean, of course, make "key" an int. Having get_key return an int that
is then stored into a char would accomplish... nothing.
Regards,
-=Dave
Express your personality in color! Prev
From: j...@uriah.heep.sax.de
> Dave Hansen wrote:
>
> > In this code=2C the handle_input function falls into an infinite loop if pl=
> > ain char is signed. This is because key gets promoted (to signed int) befo=
> > re the comparison with EXIT_KEY (which is already
From: david.br...@hesbynett.no
[...char vs. signed cahr vs. unsigned char...]
>
> Don't look it up - if you learn the compiler's default behaviour, you
> risk writing incorrect code. If it is in any way relevant whether a
> char is signed or not, write "signed char" or "unsigned char" explici
From: d...@mobilefusioninc.com
[...]
I'm still puzzled as to why the compiler didn't change:
// This takes 53uS at 4 MHz
Bin = ( A / Data_Divisor ) // Data_Divisor is a constant, 32.
into
// This takes 8.9uS at 4 MHz
Bin = ( A >> 5)
Just guessing, but it may be trying to preserve trunc
From: bernard.fou...@kuantic.com
[...re: volatile use cases...]
> fourth case: nasty situations where 'volatile' is only a part of the
> solution but does not insure a correct result:
>
> For instance if ISR1 and ISR2 are *nested* ISRs, IsrCounter does not
> correctly hold the count of int
From: vincent.trouill...@modulonet.fr
[...]
>
>> ISO C99, section 6.4.4.4, p3:
>> the question-mark ?, [..] is representable according to the following table
>> of escape
>> sequences: question mark? \?
>
> Interesting. I wonder why the standard deeemd it necessary to provide
> an escape sequenc
From: dke...@hiwaay.net
> On Thu, Feb 05, 2009 at 12:13:37AM -0700, Chris Kuethe wrote:
>> On Thu, Feb 5, 2009 at 12:10 AM, Schwichtenberg, Knut
>> wrote:
>>> As far as I know hex values won't work as expected but octal does!
>>>
>>> I used:
>>>
>>> static char s46[] __attribute__ ((progmem))
From: dke...@hiwaay.net[...]> Notice the starting address of eeprom is 1 byte
above the physical> address of start of eeprom because there was some rumor
stating some> models of AVR would accidentally trash the first byte under some>
circumstances. Perhaps when the rest of the device was wiped
For a PDP-8, CHAR_BIT would be 12, int could have 24 bits, and long could have
36 or 48, whatever is most convenient/efficient/desired.
For a PDP-15, char and int could be the same 18-bit type, and long could be 36
bits.
On further reflection, you might be able to replace the standard 16 bit
From: [EMAIL PROTECTED]
> 2008/7/14 Weddington, Eric <[EMAIL PROTECTED]>:> > A 24-bit integer is not
> supported by the C language. In theory, support> > could be added to GCC, but
> then it would be considered an extension to> > the C language. And it would
> also be difficult and/or time-cons
> From: [EMAIL PROTECTED]
>
> The point I was trying to make (poorly) was that io (and other
> variables) that may universally declared volatile, may in fact have
> values that need to be used in a "non-volatile" fashion.
>
> You have same problem with unrollable operations such as:
>
>
From: [EMAIL PROTECTED]
> > For instance I recovered chips sometimes by using UART traffic because
> > I had no other hardware at hand: I took a RS232-UART converter, sent a
> > big file from a terminal emulator (with no particular protocol, just raw
> > byte sending) and I tried a few times
> From: [EMAIL PROTECTED]
>
> Hi,
>
> On Mon, 01 Oct 2007 13:02:32 +0530, David Brown <[EMAIL PROTECTED]> wrote:
> > Royce Pereira wrote:
> >>
> >> So I have to write more 'C' code :) to get the same stuff done, in
> >> the 'new & smarter' compiler! Interesting.
> >>
> >> Doesn't seem right,
> Date: Fri, 28 Sep 2007 14:21:38 +0530> To: [EMAIL PROTECTED]> Subject: Re:
> [avr-gcc-list] Problem with delay loop> From: [EMAIL PROTECTED]> CC:
> AVR-GCC-list@nongnu.org> > Hi,> > On Fri, 28 Sep 2007 13:42:18 +0530, Klaus
> Rudolph <[EMAIL PROTECTED]> wrote:> > > The code has been optimized
From: "Graham Davies" <[EMAIL PROTECTED]>
David Brown wrote:
I believe [the compiler] can [change order of ... volatile objects
access].
Obviously it is only legal if such moves do not affect the volatile
accesses themselves. Perhaps someone here who has a better knowledge of
the standard
From: "Gerard Marull Paretas" <[EMAIL PROTECTED]>
> Paulo Marques:
> I think you just answered your own question: if all the variables
involved
are uint16_t, then that is the precision used for all he expression and it
will overflow on the multiplication.
The same happens whether if currentson
From: [EMAIL PROTECTED]
For the C code:
uint8_t tx_producer_index;
...
{
...
uint8_t temp = (tx_producer_index + 1) % 64;
Note that the literals 1 and 64 have type int, so tx_producer_index is
promoted to int before the addition, and the % must be performed on signed
operands.
I ge
From: Bob Paddock <[EMAIL PROTECTED]>
[...]
What I've never understood at all is why are characters signed
in any case?What exactly is the meaning of a negative-letter-"A"?
It's all hysterical raisins.
The earliest C compilers made char signed by default because ASCII only
requires 7 bit
From: Eric Weddington <[EMAIL PROTECTED]>
> From: Schwichtenberg, Knut [mailto:[EMAIL PROTECTED]
[...]
> Eric, the point is not that I don't like the output, but the
> case to be
> selected should be deterministic. I always thought that a switch
> statement would lead to identical results if t
From: alee <[EMAIL PROTECTED]>
Why does avr-gcc delete my empty "for" loops if I compile with optimization
on?
I am able to preserve the loop if I add a NOP in the loop but that will eat
up one clock cycle. Is there a way to preserve the empty loops without
adding any NOP clock cycles? Is thi
From: "Graham Davies" <[EMAIL PROTECTED]>
Bob Paddock wrote:
[...]
I don't see while(true){} being any different than for(;;){}
in this context, and while(true){} causes the Lint error
of "evaluation of constant value boolean".
[...]
I can't see why Lint would consider this an error and for
From: "Graham Davies" <[EMAIL PROTECTED]>
David Brown wrote (in part):
... I don't know if the C standard is clear on expressions such as "a = b
= c", when some or all of these are volatile ...
It is clear. The assignment operator has right-to-left associativity so b
= c is evaluated firs
From: Paulo Marques <[EMAIL PROTECTED]>
Dave Hansen wrote:
[...]
You've opened some new cans of worms here, but I'll only make one small
comment
I was afraid of that (the cans of worms, not your comment) ;)
Thanks for noticing the implied smiley. Looking at what I wrot
From: Paulo Marques <[EMAIL PROTECTED]>
Graham Davies wrote:
"David Brown" wrote:
You are missing a number of points ...
Well, I think we're getting close to complete coverage now!
Well, since we are going for complete coverage, I'll add my 2 cents, then.
You've opened some new cans of w
From: Simon Han <[EMAIL PROTECTED]>
[...]
To reply my own question. :-)
The problem is that gcc does sign extension to the value.
Changing to value less than 0x7fe fixed the problem.
Simon
On Oct 31, 2006, at 9:30 PM, Simon Han wrote:
Hi all,
I am trying to call functions with hard
From: "Sumeet Pal Singh" <[EMAIL PROTECTED]>
[...]
Can someone suggest some way(part of code of Makefile to change) to make
avr-gcc to compile irrespective of whether the source file has been
modified
on not. I am not good in shell scripting.
If I understand what you're asking for, all y
From: "rajeev joshi" <[EMAIL PROTECTED]>
[...]
4.While working on windows which compiler, simulator shpuld use ,right now
i
m having codevision AVR ,AVR studio .
5. But i m not gettin how to work on WINAVR .
What is your goal?
If you have to get a project out, and you have a paid license for
From: "MuRaT KaRaDeNiZ" <[EMAIL PROTECTED]>
So
U08 RX485_oldbyte1; is uninitialized data, but compiler also initialize
it to zero, why is it different from inline initialization during
declaration, I expect the compiler just replace the zero with the
initial value i provide?
Because reality i
From: "Flemming Steffensen (sent by Nabble.com)" <[EMAIL PROTECTED]>
[...]
I noticed the problem using this code:
unsigned short RotCount;
SIGNAL(SIG_INTERRUPT0){
RotCount++;
}
void test(void){
while (1){
RotCount = 0;
while (RotCou
From: "bolet (sent by Nabble.com)" <[EMAIL PROTECTED]>
[...]
The program works OK without optimization. It doesn't work with
optimization (-o1). The code is:
...includes...
const char P_Txt[] PROGMEM = "Just a test..";
volatile PGM_P txt= P_Txt;
int main (void)
{
...Init code ... (reg setu
From: [EMAIL PROTECTED]
[...]
#include
int somma(int a, int b)
{
return a+b;
}
int main ()
{ int e = 10;
int r = 1;
r = somma(e,r);
r=r+1;
return r;
}
it's a stupid program. When deb
From: "varsha" <[EMAIL PROTECTED]>
hello all,
i am using avr-gcc (GCC) 3.4.3, and using ATmega16 ,
and writng the code for copying sdram data int flash, in c language.
There are three address bytes and three length bytes for sdram.
At a time i can read 16 bytes from sdram, then i want to decerme
From: David Kelly <[EMAIL PROTECTED]>
[...]
People keep saying "C isn't fast enough." I don't belive it. First
attempt:
#include
#define CLOCK_B (1<<0)
#define BIT_B (1<<1)
void
myjunk(uint8_t byte) {
uint8_t i;
for( i = 0 ; i < 8 ; i++ ) {
PORTA |= CLOCK_B;
From: Vincent Trouilliez <[EMAIL PROTECTED]>
> FWIW, I always had good luck with the delay functions in delay.h for
short
> hardcoded (usec) delays.
Lucky you ! Other than wanting to avoid all this in-line stuff, the
reason I replaced _delay_us(40) in my lcd routine, by an empty for loop,
is
From: "David Brown" <[EMAIL PROTECTED]>
[...]
The bug is almost certainly a delay loop variable that is not declared
volatile. The delay function is probably something like:
void shortDelay(void) {
uint8_t n = 50;
while (n--);
}
That (might) work fine with little or no optomisation, bu
From: Vincent Trouilliez <[EMAIL PROTECTED]>
[...]
About the -Os flag, I noticed this morning that it managed MASSIVE code
size reduction ! SO far I had been using just -O (I guess that means no
particular optimisation ?), and the program is about 13KB in size. With
-Os, it's only 10KB !!! Sad
From: Eric Weddington <[EMAIL PROTECTED]>
Torsten Landschoff wrote:
Hi,
I was wondering why assert.h is missing on avr. I am writing my own
assert.h over and over so I'd like to have it in avr-libc as I assume
that others would like to have it as well.
The default action on assertion failure
From: Patrick Blanchard <[EMAIL PROTECTED]>
On Fri, 2005-10-07 at 08:24 -0700, Razvan Turiac wrote:
> I think I have a compile problem. I am using WinAVR
> 20050214 and I've got one problem when compiling some
> code.
OK, but you need to show us the compiler errors received...
You have to sca
From: Vincent Trouilliez <[EMAIL PROTECTED]>
Hi list,
I have been advised to use CVS when developing programs, but it seems
awkward to set up the server side. While asking around for help, I have
been suggested to give up CVS and use SVN, "subversion", instead, and
that it was meant to supplan
From: Vincent Trouilliez <[EMAIL PROTECTED]>
[...]
What more could I possibly want ? Well, there is one thing actually:
the pointer points to a function, any function. However if the item is
actually a sub-menu, then the 'menu_item' structure needs to store a
pointer to a 'menu' structure, so tha
From: Vincent Trouilliez <[EMAIL PROTECTED]>
[...]
However, something still causes me trouble apparently
The actual/complete declaration of my "menu" data type / structure is :
struct menu {
uint8_t options; //options to control the operation of the menu
uint8_t nb; //nu
From: Vincent Trouilliez <[EMAIL PROTECTED]>
[...]
Problem: my function pointers are in an array, within a structure, which
itself is accessed via pointers... oh dear.
[...]
//data type for a menu
struct menu {
.;
.;
int (*fp)()[]; //table to store all the poin
From: Jonathan Goldberg <[EMAIL PROTECTED]>
Anyone have a good lint configuration file for avr-gcc?
You don't say which lint.
Here's the one I'm using for a current project under Ginpel's PC-lint.
--- begin included file ---
// Compiler definitions
//
c:\lint\lnt\co-gnu3.lnt // 2.95.3
From: "Bob Paddock" <[EMAIL PROTECTED]>
I thought I'd try this bitmap 'trick' via copy&paste of the
#defines and code into the file I was working on, this is what I get:
Name/name.c:692: error: `sXX__' undeclared here (not in a function)
Name/name.c:692: error: initializer element is not co
From: Richard Urwin <[EMAIL PROTECTED]>
On Tuesday 20 Sep 2005 15:04, Dave Hansen wrote:
[...re: i = i++...]
> The standard says that the value of a variable should only be
> modified once between sequence points. The expression "i = i++;"
> attempts to modi
From: Alan Kilian <[EMAIL PROTECTED]>
[...]
Here's an excerpt from:
http://publications.gbdirect.co.uk/c_book/chapter8/sequence_points.html
"This is why you cannot rely on expressions such as:
a[i] = i++;
because there is no sequence point specified for the
From: "David Brown" <[EMAIL PROTECTED]>
- Original Message -
From: "Trampas" <[EMAIL PROTECTED]>
> I was helping a friend debug some code, he is new to C, using the Keil
> version of GCC for ARM. Anyway I found the following:
>
> int i;
>
> i=0;
> i=i++;
> //i was still zero that
[...]
From: David Kelly <[EMAIL PROTECTED]>
[...]
char buffer[4];
uint8_t i;
strncpy_P( buffer, PGM_P("000"), 3 );
i = 2;
while(x) {
buffer[i--] = x%10 + '0';
x = x/10;
}
putchar(buffer[0]);
putchar('.');
putchar(buffer[1]);
putchar(buffer[2]);
From: "Anton Erasmus" <[EMAIL PROTECTED]>
On 14 Sep 2005 at 6:21, John Altstadt wrote:
[...]
> %.elf: $(OBJ)
> @echo
> @echo $(MSG_LINKING) $@
> $(CC) $(ALL_CFLAGS) $^ --output $@ $(LDFLAGS)
> rm version.o
There is a better way to force the recompile of ver
From: [EMAIL PROTECTED] (Joerg Wunsch)
[EMAIL PROTECTED] wrote:
> I would like to display a "code version" (date/time or incremental
> number) during init on an LCD display.
If you're using CVS, you can get the date of the last checkin of
a particular module by
const char foo[] = "$Date$";
From: "Anton Erasmus" <[EMAIL PROTECTED]>
[...]
> I tried to calculate the baud rate on scope, I found I
> can't get a exactly number, I can only get an
> estimate. Do you know if there's way to set the baud
> rate accurately?
Send 0xAA continiously. That way you get a nice
square wave at the ba
From: Joerg Wunsch <[EMAIL PROTECTED]>
As Wojtek Kaniewski wrote:
> What about the SIG_ prefix? If we'll move to something else than
> SIGNAL(), I think that it should be dropped or somehow hidden from
> the users.
Very good point. I've been thinking about adding a second set of
vector names
From: User Tomdean <[EMAIL PROTECTED]>
[...]
The ATmega16 datasheet states, in part,
[...]
resoultion. If a lower resolution than 10 bits is needed, the input
clock frequency to the ADC can be higher than 200 kHz to get a
higher sample rate.
The datasheet does not specify the reduction
From: Dave Hylands <[EMAIL PROTECTED]>
> Be warned that the head/tail usage can be something of a religious
> war with people. There are those who champion the opposite roles
> of head/tail, and remember it with "when you join a queue, should you
> join at the head or the tail ?" - so if you
From: "Royce Pereira" <[EMAIL PROTECTED]>
Hi,
Is there a macro to read or write a long word (32 bits) to eeprom?
For the last hour I've been trying to write one unsuccessfully.
Not directly, but you can do something like
#include
inline void eeprom_write_long(long *dest, long val)
{
From: "Haase Bjoern (PT-BEU/EMT) *" <[EMAIL PROTECTED]>
[EMAIL PROTECTED] wrote:
>Hello,
>
>for code portability reasons, I would like to avoid to call explicity the
>function pgm_read_byte() like in the following example :
>
>const prog_char array[7] = {0x10,0x20,0x30,0x40,0x50,0x60,0x70};
>y
From: jeffrey traer bernstein <[EMAIL PROTECTED]>
[...]
void (*funcptr)( void ) = 0x;
funcptr();
okay here's another stab in the dark. when you make a function pointer and
initialize it with an address (0x in the case) is it the data i.e. the
address stored in the .data sectio
From: Torsten Mohr <[EMAIL PROTECTED]>
[...]
i have a functionpointer that is located in the variable fptr:
uint32_t fptr;
I'd now like to jump to that location.
From the avr-libc-user-manual-1.2.3 i thought i'd need to put it like this:
asm("ijmp":: "x" (fptr / 2));
Just a guess, because I
From: "Trampas" <[EMAIL PROTECTED]>
I don't think that is portable. That is I know some 16 bit processors and
It's not, but not for the reason you specify.
compilers will report an INT16 as being sizeof 1. That is sizeof for word
If sizeof(int16_t) == 1, then CHAR_BIT == 16.
addressable
From: Dean Hall <[EMAIL PROTECTED]>
[...]
Using volatile can then become confusing for a trivial fragment such as
this:
volatile v = 42;
v = ((v=12) | (~v) | (!v));
Does this cause two loads of v? Is v equal to twelve or forty two when ~v
is executed? Answers are left as an exercise to the re
63 matches
Mail list logo