Re: [avr-gcc-list] OT Generic C question

2005-09-22 Thread Dave Hansen
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

Re: [avr-gcc-list] OT Generic C question

2005-09-22 Thread Dave Hansen
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

Re: [avr-gcc-list] Trick for creating WYSIWYG bitmaps in C [was: howto specifiy a binary constant]

2005-09-23 Thread Dave Hansen
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

RE: [avr-gcc-list] Lint and avr-gcc

2005-09-26 Thread Dave Hansen
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

RE: [avr-gcc-list] calling function pointers via pointers ?

2005-09-28 Thread Dave Hansen
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

Re: [avr-gcc-list] calling function pointers via pointers ?

2005-09-28 Thread Dave Hansen
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

Re: [avr-gcc-list] calling function pointers via pointers ?

2005-09-29 Thread Dave Hansen
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

RE: [avr-gcc-list] CVS or SVN ?!

2005-09-30 Thread Dave Hansen
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

Re: [avr-gcc-list] Compile problem

2005-10-07 Thread Dave Hansen
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

Re: [avr-gcc-list] assert.h not available!?

2005-10-29 Thread Dave Hansen
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

Re: [avr-gcc-list] How to (efficeiently !!!) test a bit withinamulti-byte intege

2005-11-04 Thread Dave Hansen
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

Re: [avr-gcc-list] How to (efficeiently !!!) test abitwithinamulti-byte intege

2005-11-04 Thread Dave Hansen
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

Re: [avr-gcc-list] How to (efficeiently !!!) testabitwithinamulti-byte intege

2005-11-07 Thread Dave Hansen
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

Re: [avr-gcc-list] AVR assembly for fast bit bang

2005-11-09 Thread Dave Hansen
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;

RE: [avr-gcc-list] sdram adress/length

2005-11-10 Thread Dave Hansen
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

RE: [avr-gcc-list] Problem with debbuggin with AVRStudio, WinAvr and JtagIce mkII

2005-11-16 Thread Dave Hansen
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

RE: [avr-gcc-list] Program Space String & optimization

2005-12-14 Thread Dave Hansen
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

RE: [avr-gcc-list] BUG? Comparing of words error.

2006-01-18 Thread Dave Hansen
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

RE: [avr-gcc-list] (no subject)

2006-01-30 Thread Dave Hansen
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

RE: [avr-gcc-list] query please help

2006-03-07 Thread Dave Hansen
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

RE: [avr-gcc-list] Makefile Changes

2006-07-09 Thread Dave Hansen
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

Re: [avr-gcc-list] Calling function with hard coded address

2006-11-01 Thread Dave Hansen
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

Re: [avr-gcc-list] volatile...

2006-12-15 Thread Dave Hansen
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

Re: [avr-gcc-list] volatile...

2006-12-15 Thread Dave Hansen
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

Re: [avr-gcc-list] Wrong excution order in 4.1.1, but not 3.4.5, regression?

2007-02-20 Thread Dave Hansen
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

Re: [avr-gcc-list] Should this code work? 4.1.1

2007-03-05 Thread Dave Hansen
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

RE: [avr-gcc-list] loop deleted using optimization

2007-03-06 Thread Dave Hansen
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

RE: [avr-gcc-list] Inconsisten behaviour of switch statement

2007-03-26 Thread Dave Hansen
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

Re: [avr-gcc-list] New GCC warning - how to silence?

2007-04-09 Thread Dave Hansen
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

RE: [avr-gcc-list] GCC does useless 16-bit operations

2007-05-11 Thread Dave Hansen
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

Re: [avr-gcc-list] Operation problem

2007-08-11 Thread Dave Hansen
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

Re: [avr-gcc-list] avr-g++ local variable constructor / block body/destructor ex

2007-09-06 Thread Dave Hansen
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

RE: [avr-gcc-list] Problem with delay loop

2007-09-28 Thread Dave Hansen
> 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

RE: [avr-gcc-list] Problem with delay loop

2007-10-02 Thread Dave Hansen
> 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,

RE: [avr-gcc-list] ATMega32 fuse bit problem

2007-11-13 Thread Dave Hansen
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

RE: [avr-gcc-list] Tip: handling volatile operands

2008-01-11 Thread Dave Hansen
> 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: > >

RE: [avr-gcc-list] 24 bit Integer

2008-07-30 Thread Dave Hansen
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

RE: [avr-gcc-list] 24 bit Integer

2008-07-30 Thread Dave Hansen
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

Slightly OT: AVR EEPROM Location 0 (was RE: [avr-gcc-list] address@hidden ... what is it for ?!)

2009-01-06 Thread Dave Hansen
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

RE: [avr-gcc-list] Re: Strings: escape sequence to insert arbitrary hex value ?

2009-02-05 Thread Dave Hansen
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))

RE: [avr-gcc-list] Re: Strings: escape sequence to insert arbitrary hex value ?

2009-02-05 Thread Dave Hansen
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

RE: [avr-gcc-list] memcpy() : problem when passing destination pointer

2009-02-11 Thread Dave Hansen
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

RE: [avr-gcc-list] Re: Wierd Calls.

2009-03-11 Thread Dave Hansen
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

RE: [avr-gcc-list] Re: Passing a string variable to lcd_puts

2009-03-30 Thread Dave Hansen
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

RE: [avr-gcc-list] Re: Passing a string variable to lcd_puts

2009-03-30 Thread Dave Hansen
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

RE: [avr-gcc-list] Re: Passing a string variable to lcd_puts

2009-03-30 Thread Dave Hansen
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

RE: [avr-gcc-list] Rounded integral division in preprocessor

2010-02-05 Thread Dave Hansen
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

Re: [avr-gcc-list] Can enumerator values be used in a #if preprocessordirective?

2011-08-29 Thread Dave Hansen
> 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

Re: Saving & retreiving a structure in eeprom

2020-06-09 Thread Dave Hansen
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

Re: [avr-gcc-list] "Volatile"

2005-04-18 Thread Dave Hansen
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

RE: [avr-gcc-list] AVR-GCC question

2005-05-23 Thread Dave Hansen
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

RE: [avr-gcc-list] inline assembler, ijmp, X-Register

2005-07-01 Thread Dave Hansen
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

Re: [avr-gcc-list] bootloader not jumping back to app

2005-08-08 Thread Dave Hansen
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

RE: AW: [avr-gcc-list] Pgmspace.h Use

2005-08-09 Thread Dave Hansen
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

RE: [avr-gcc-list] Macro to read /write long to eeprom

2005-08-09 Thread Dave Hansen
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) {

Re: [avr-gcc-list] Problems with ATMEGA8 USART

2005-08-16 Thread Dave Hansen
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

RE: [avr-gcc-list] ATmega16 ADC at High Clock Rates

2005-08-16 Thread Dave Hansen
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

Re: [avr-gcc-list] Re: [avr-libc-dev] RFD: more avr-libc API changes

2005-09-09 Thread Dave Hansen
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

Re: [avr-gcc-list] Small program for UART not working

2005-09-12 Thread Dave Hansen
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

Re: [avr-gcc-list] Code version timestamp

2005-09-14 Thread Dave Hansen
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$";

Re: [avr-gcc-list] Code version timestamp

2005-09-14 Thread Dave Hansen
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

Re: [avr-gcc-list] Initilizing complex const arrays : syntax ?

2005-09-19 Thread Dave Hansen
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]);

Re: [avr-gcc-list] OT Generic C question

2005-09-20 Thread Dave Hansen
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 [...]