Re: [avr-gcc-list] How to force GCC to not to remove "nop" statements?

2009-02-20 Thread David Kelly
On Fri, Feb 20, 2009 at 08:00:00AM +0100, Joerg Wunsch wrote:
> David Kelly  wrote:
> 
> > Strangely the JTAGICE mkII didn't work on the above hardware where the  
> > ICE Cube did. I put a small 50 mA or maybe 100 mA linear regulator on  
> > the 3.3V supply and the mkII drew more power off the target than the  
> > regulator would provide.
> 
> The JTAG ICE mkII cannot be powered from the target circuitry.  It
> needs either a separate power supply, or can be powered directly from
> USB.

Whatever, it didn't work on my circuit but worked on a purchased
ATmega128 board. But the ICE Cube did work. I believe the company is
currently using mkII's to support it.

-- 
David Kelly N4HHE, dke...@hiwaay.net

Whom computers would destroy, they must first drive mad.


___
AVR-GCC-list mailing list
AVR-GCC-list@nongnu.org
http://lists.nongnu.org/mailman/listinfo/avr-gcc-list


Re: [avr-gcc-list] How to force GCC to not to remove "nop" statements ?

2009-02-20 Thread Vincent Trouilliez
On Fri, 20 Feb 2009 08:03:52 +0100 (MET)
j...@uriah.heep.sax.de (Joerg Wunsch) wrote:

> Vincent Trouilliez  wrote:
> > lcd.c:96: error: »asm« undeclared (first use in this function)
> 
> That's because you are using a -std setting the prevents GCC from
> using its extensions by a name ("asm") that is in the application name
> space, like -std=c99.  Either use -std=gnu99, or (as you already did)
> use the implementation namespace counterpart __asm__.
> 
> -- 
> cheers, J"org

You are a magician Joerg.. how could you know ! ;-)
Yes indeed, 2 weeks ago I added the --std=c99 flag to my makefile, as
advised by the avr-libc manual, in order to get the ATOMIC_BLOCK()
macro to work !
Using gnu99 fixed the problem indeed, thanks ! :-)



___
AVR-GCC-list mailing list
AVR-GCC-list@nongnu.org
http://lists.nongnu.org/mailman/listinfo/avr-gcc-list


Re: [avr-gcc-list] How to force GCC to not to remove "nop" statements ?

2009-02-19 Thread Joerg Wunsch
Vincent Trouilliez  wrote:

> lcd.c:96: error: »asm« undeclared (first use in this function)

That's because you are using a -std setting the prevents GCC from
using its extensions by a name ("asm") that is in the application name
space, like -std=c99.  Either use -std=gnu99, or (as you already did)
use the implementation namespace counterpart __asm__.

-- 
cheers, J"org   .-.-.   --... ...--   -.. .  DL8DTL

http://www.sax.de/~joerg/NIC: JW11-RIPE
Never trust an operating system you don't have sources for. ;-)


___
AVR-GCC-list mailing list
AVR-GCC-list@nongnu.org
http://lists.nongnu.org/mailman/listinfo/avr-gcc-list


Re: [avr-gcc-list] How to force GCC to not to remove "nop" statements ?

2009-02-19 Thread Joerg Wunsch
Vincent Trouilliez  wrote:

> "Unfortunately" I am on Linux so no WinAVR for me ! ;-)

Once I'm done with updating the FreeBSD toolchain (see the other
part of this thread), Bingo600's Linux build script will also
track that as well.

-- 
cheers, J"org   .-.-.   --... ...--   -.. .  DL8DTL

http://www.sax.de/~joerg/NIC: JW11-RIPE
Never trust an operating system you don't have sources for. ;-)


___
AVR-GCC-list mailing list
AVR-GCC-list@nongnu.org
http://lists.nongnu.org/mailman/listinfo/avr-gcc-list


Re: [avr-gcc-list] How to force GCC to not to remove "nop" statements?

2009-02-19 Thread Joerg Wunsch
David Kelly  wrote:

> Strangely the JTAGICE mkII didn't work on the above hardware where the  
> ICE Cube did. I put a small 50 mA or maybe 100 mA linear regulator on  
> the 3.3V supply and the mkII drew more power off the target than the  
> regulator would provide.

The JTAG ICE mkII cannot be powered from the target circuitry.  It
needs either a separate power supply, or can be powered directly from
USB.

-- 
cheers, J"org   .-.-.   --... ...--   -.. .  DL8DTL

http://www.sax.de/~joerg/NIC: JW11-RIPE
Never trust an operating system you don't have sources for. ;-)


___
AVR-GCC-list mailing list
AVR-GCC-list@nongnu.org
http://lists.nongnu.org/mailman/listinfo/avr-gcc-list


Re: [avr-gcc-list] How to force GCC to not to remove "nop" statements?

2009-02-19 Thread Royce Pereira

Hi,
- Original Message - 
From: "David Kelly" 

To: 
Sent: Friday, 20 February, 2009 1:30 AM
Subject: Re: [avr-gcc-list] How to force GCC to not to remove "nop" 
statements?





Related to another thread: as to why *not* to use an 8051:
Doesn't have avr-gcc.


But it does have SDCC, a freeware C compiler for MCS51.
I used it when I began with 89C51.
Being built from scratch, it has some features I miss in AVR-GCC ( like not 
having to use macros for flash/eeprom  access etc. )


BTW, I use only AVRs now, more for their rich features (eg. ADC).

--Royce.



___
AVR-GCC-list mailing list
AVR-GCC-list@nongnu.org
http://lists.nongnu.org/mailman/listinfo/avr-gcc-list


Re: [avr-gcc-list] How to force GCC to not to remove "nop" statements?

2009-02-19 Thread David Kelly


On Feb 19, 2009, at 5:47 PM, Jim Brain wrote:

So true.  Althought it's pointless to add to the recent Freaks "AVR  
vs PIC" thread, this is one of the most significant reasons why I  
prefer the AVR line.  They are inexpensive, the programmers can be  
very inexpensive, and the C toolchain is easily within reach of the  
hobbyist.


I have $40.00 in PICs and a nice programmer sitting usb programmer  
for them I have never used.  I just can't find the value in jumping  
back to ASM to make use of them.



I have a Microchip 1000 or 2000 ICE thingy that cost about $2000 and  
was used for one project.


Given a choice I much prefer the ECROS ICE Cube, avr-gcc, and of  
course an AVR. With AVR prices the way they have been I have an easy  
argument for AVR. My use of AVR isn't big by some measures but about  
2500 ATmega64L's per year the past 4 years are running my code.


Strangely the JTAGICE mkII didn't work on the above hardware where the  
ICE Cube did. I put a small 50 mA or maybe 100 mA linear regulator on  
the 3.3V supply and the mkII drew more power off the target than the  
regulator would provide. Didn't know that for a long time because the  
ICE Cube worked so well.


--
David Kelly N4HHE, dke...@hiwaay.net

Whom computers would destroy, they must first drive mad.



___
AVR-GCC-list mailing list
AVR-GCC-list@nongnu.org
http://lists.nongnu.org/mailman/listinfo/avr-gcc-list


Re: [avr-gcc-list] How to force GCC to not to remove "nop" statements?

2009-02-19 Thread Jim Brain

David Kelly wrote:

Related to another thread: as to why *not* to use an 8051:
Doesn't have avr-gcc.
  
So true.  Althought it's pointless to add to the recent Freaks "AVR vs 
PIC" thread, this is one of the most significant reasons why I prefer 
the AVR line.  They are inexpensive, the programmers can be very 
inexpensive, and the C toolchain is easily within reach of the hobbyist.


I have $40.00 in PICs and a nice programmer sitting usb programmer for 
them I have never used.  I just can't find the value in jumping back to 
ASM to make use of them.


Jim


___
AVR-GCC-list mailing list
AVR-GCC-list@nongnu.org
http://lists.nongnu.org/mailman/listinfo/avr-gcc-list


Re: [avr-gcc-list] How to force GCC to not to remove "nop" statements?

2009-02-19 Thread David Kelly
On Thu, Feb 19, 2009 at 12:46:50PM -0700, Weddington, Eric wrote:
>  
> > Hey Joerg, you must be busy! FreeBSD's avr-gcc used to track WinAVR
> > closer than this.  :-)
> 
> He has been busy. He's been working on support for the new
> ATmega128RFA1 device, which has been added recently to the toolchain.
> Joerg will be including all of the WinAVR patches in his next update
> of the avr toolchain in FreeBSD Ports.
> 
> Joerg and I are working closely on the next release. There's been a
> lot of activity recently on avr-libc and avrdude, with releases of
> both coming up very soon.

Thought I ought to reply to make sure its clear that I'm not complaining
and very much appreciate the work Eric and Joerg are doing and have done
for avr-gcc.

Related to another thread: as to why *not* to use an 8051:
Doesn't have avr-gcc.

-- 
David Kelly N4HHE, dke...@hiwaay.net

Whom computers would destroy, they must first drive mad.


___
AVR-GCC-list mailing list
AVR-GCC-list@nongnu.org
http://lists.nongnu.org/mailman/listinfo/avr-gcc-list


RE: [avr-gcc-list] How to force GCC to not to remove "nop" statements?

2009-02-19 Thread Weddington, Eric
 

> -Original Message-
> From: 
> avr-gcc-list-bounces+eweddington=cso.atmel@nongnu.org 
> [mailto:avr-gcc-list-bounces+eweddington=cso.atmel@nongnu.
> org] On Behalf Of David Kelly
> Sent: Thursday, February 19, 2009 12:36 PM
> To: avr-gcc-list@nongnu.org
> Subject: Re: [avr-gcc-list] How to force GCC to not to remove 
> "nop" statements?
> 
> On Thu, Feb 19, 2009 at 11:14:40AM -0700, Weddington, Eric wrote:
> >  
> > If you are using WinAVR 20081205 then you can use one of the new
> > builtin functions:
> > 
> > void __builtin_avr_delay_cycles(unsigned long __n);
> > 
> > The prototype can be found in , but you 
> shouldn't need
> > the prototype to call it.
> 
> Hey Joerg, you must be busy! FreeBSD's avr-gcc used to track WinAVR
> closer than this.  :-)

He has been busy. He's been working on support for the new ATmega128RFA1 
device, which has been added recently to the toolchain. Joerg will be including 
all of the WinAVR patches in his next update of the avr toolchain in FreeBSD 
Ports.

Joerg and I are working closely on the next release. There's been a lot of 
activity recently on avr-libc and avrdude, with releases of both coming up very 
soon.


___
AVR-GCC-list mailing list
AVR-GCC-list@nongnu.org
http://lists.nongnu.org/mailman/listinfo/avr-gcc-list


Re: [avr-gcc-list] How to force GCC to not to remove "nop" statements ?

2009-02-19 Thread David Kelly
On Thu, Feb 19, 2009 at 11:14:40AM -0700, Weddington, Eric wrote:
>  
> If you are using WinAVR 20081205 then you can use one of the new
> builtin functions:
> 
> void __builtin_avr_delay_cycles(unsigned long __n);
> 
> The prototype can be found in , but you shouldn't need
> the prototype to call it.

Hey Joerg, you must be busy! FreeBSD's avr-gcc used to track WinAVR
closer than this.  :-)

-- 
David Kelly N4HHE, dke...@hiwaay.net

Whom computers would destroy, they must first drive mad.


___
AVR-GCC-list mailing list
AVR-GCC-list@nongnu.org
http://lists.nongnu.org/mailman/listinfo/avr-gcc-list


Re: [avr-gcc-list] How to force GCC to not to remove "nop" statements ?

2009-02-19 Thread Vincent Trouilliez
On Thu, 19 Feb 2009 10:22:23 -0800 (PST)
Parthasaradhi Nayani  wrote:

> Hi Vincent,
> If I understand correctly, the word "volatile" itself is to tell the compiler 
> not to ignore the statement. I am not sure if your statement is correct, but 
> I have used
> 
>  "asm volatile ("nop"::);"

I used this too, because it's what the avr-libc manual shows, however
when I do this, GCC caughs :

lcd.c:96: error: ‘asm’ undeclared (first use in this function)
lcd.c:96: error: (Each undeclared identifier is reported only once
lcd.c:96: error: for each function it appears in.)
lcd.c:96: error: expected ‘;’ before ‘volatile’
make: *** [lcd.o] Error 1

the same avr manual (section 9.6.5, "macros") suggests that using
__asm__ instead of asm (and same for volatile) might help get rid of
warnings. So I tried that and it worked.. so I stick with it ;-)


--
Vince


___
AVR-GCC-list mailing list
AVR-GCC-list@nongnu.org
http://lists.nongnu.org/mailman/listinfo/avr-gcc-list


Re: [avr-gcc-list] How to force GCC to not to remove "nop" statements ?

2009-02-19 Thread Vincent Trouilliez
On Thu, 19 Feb 2009 19:21:07 +0100
Ruud Vlaming  wrote:

> Are you absolutely sure they are really left out?  I assume they are
> just not shown in the assembly file. Four or more nops are replaced
> by ellipses, but are present allright. Have a close look at the addresses.

Oooops ! Can you see the red on my face ?! ;-)
Indeed you are right, with 4 nops, the assembly looks like this:


fa4:db 9a   sbi 0x1b, 3 ; 27
...
fb6:db 98   cbi 0x1b, 3 ; 27
fb8:08 95   ret

I apologize ! It's just that I didn't know GCC behaved like this, so I wasn't 
watching for it !

> Otherwise you could use 
>   __asm__ volatile(
> "nop \n\t"
> "nop \n\t"
> "nop \n\t"
> "nop \n\t");
> in which gcc cannot start to optimize.

I take note...



--
Vince, embarassed...


___
AVR-GCC-list mailing list
AVR-GCC-list@nongnu.org
http://lists.nongnu.org/mailman/listinfo/avr-gcc-list


Re: [avr-gcc-list] How to force GCC to not to remove "nop" statements ?

2009-02-19 Thread Vincent Trouilliez
On Thu, 19 Feb 2009 11:14:40 -0700
"Weddington, Eric"  wrote:

> If you are using WinAVR 20081205 then you can use one of the new builtin 
> functions:
> void __builtin_avr_delay_cycles(unsigned long __n);

Hmm, sweet !
"Unfortunately" I am on Linux so no WinAVR for me ! ;-)

--
Vince


___
AVR-GCC-list mailing list
AVR-GCC-list@nongnu.org
http://lists.nongnu.org/mailman/listinfo/avr-gcc-list


Re: [avr-gcc-list] How to force GCC to not to remove "nop" statements ?

2009-02-19 Thread Parthasaradhi Nayani
Hi Vincent,
If I understand correctly, the word "volatile" itself is to tell the compiler 
not to ignore the statement. I am not sure if your statement is correct, but I 
have used

 "asm volatile ("nop"::);"

and the compiler never removed the "nop"s from code. 

Nayani

--- On Thu, 2/19/09, Vincent Trouilliez  wrote:
From: Vincent Trouilliez 
Subject: [avr-gcc-list] How to force GCC to not to remove "nop" statements ?
To: "avr-gcc-list@nongnu.org" 
Date: Thursday, February 19, 2009, 11:31 PM

Hi list,

Like many people I guess, I am using in-lined "nop" asm statements to
respect the timing of external devices, when toggling their control
lines.

In the case at hand I am driving a text LCD module, and the 
"Enable" line must be pulsed low for 250ns.

void lcd_send_nibble(uint8_t data)
{
...
//pulse Enable line
LCD_PORT |= LCD_E;
__asm__ volatile("nop");
__asm__ volatile("nop");
__asm__ volatile("nop");
__asm__ volatile("nop");
LCD_PORT &= ~LCD_E;

}


My AVR was running at 8MHz, so an instruction cycle of 125ns, so two nop
in-lined were spot on, just perfect, and it ran fine.

Today I pushed the AVR (ATmega32) up to its maximum of 16MHz.
So I now need 4 nops not two. So I did that.. and the LCD doesn't work
reliably. Suspecting the problem, I went straight to the generated
assembly, and horror, my 4 nop statements have disappeared !

I made a few trials. It appears that up to and including 3 nop
statements, GCC leaves them alone. But if I put 4 of them, it removes
them all ! 

Any way to instruct GCC to leave my 4 nops ?

Am using avr-gcc 4.3.2


Regards,

--
Vince


___
AVR-GCC-list mailing list
AVR-GCC-list@nongnu.org
http://lists.nongnu.org/mailman/listinfo/avr-gcc-list



  ___
AVR-GCC-list mailing list
AVR-GCC-list@nongnu.org
http://lists.nongnu.org/mailman/listinfo/avr-gcc-list


Re: [avr-gcc-list] How to force GCC to not to remove "nop" statements ?

2009-02-19 Thread Ruud Vlaming
On Thursday 19 February 2009 19:01, Vincent Trouilliez wrote:

> I made a few trials. It appears that up to and including 3 nop
> statements, GCC leaves them alone. But if I put 4 of them, it removes
> them all ! 
Are you absolutely sure they are really left out?  I assume they are
just not shown in the assembly file. Four or more nops are replaced
by ellipses, but are present allright. Have a close look at the addresses.

Otherwise you could use 
  __asm__ volatile(
"nop \n\t"
"nop \n\t"
"nop \n\t"
"nop \n\t");
in which gcc cannot start to optimize.

Ruud


___
AVR-GCC-list mailing list
AVR-GCC-list@nongnu.org
http://lists.nongnu.org/mailman/listinfo/avr-gcc-list


RE: [avr-gcc-list] How to force GCC to not to remove "nop" statements ?

2009-02-19 Thread Weddington, Eric
 

> -Original Message-
> From: 
> avr-gcc-list-bounces+eweddington=cso.atmel@nongnu.org 
> [mailto:avr-gcc-list-bounces+eweddington=cso.atmel@nongnu.
> org] On Behalf Of Vincent Trouilliez
> Sent: Thursday, February 19, 2009 11:02 AM
> To: avr-gcc-list@nongnu.org
> Subject: [avr-gcc-list] How to force GCC to not to remove 
> "nop" statements ?
> 
> Hi list,
> 
> Like many people I guess, I am using in-lined "nop" asm statements to
> respect the timing of external devices, when toggling their control
> lines.
> 
 
> Am using avr-gcc 4.3.2
> 

If you are using WinAVR 20081205 then you can use one of the new builtin 
functions:

void __builtin_avr_delay_cycles(unsigned long __n);

The prototype can be found in , but you shouldn't need the 
prototype to call it.

The parameter is expecting the number of cycles that you want to delay, so in 
your case this should be:

__builtin_avr_delay_cycles(4);

And then let gcc handle generating the code for you. ;-)

Eric Weddington


___
AVR-GCC-list mailing list
AVR-GCC-list@nongnu.org
http://lists.nongnu.org/mailman/listinfo/avr-gcc-list


[avr-gcc-list] How to force GCC to not to remove "nop" statements ?

2009-02-19 Thread Vincent Trouilliez
Hi list,

Like many people I guess, I am using in-lined "nop" asm statements to
respect the timing of external devices, when toggling their control
lines.

In the case at hand I am driving a text LCD module, and the 
"Enable" line must be pulsed low for 250ns.

void lcd_send_nibble(uint8_t data)
{
...
//pulse Enable line
LCD_PORT |= LCD_E;
__asm__ volatile("nop");
__asm__ volatile("nop");
__asm__ volatile("nop");
__asm__ volatile("nop");
LCD_PORT &= ~LCD_E;

}


My AVR was running at 8MHz, so an instruction cycle of 125ns, so two nop
in-lined were spot on, just perfect, and it ran fine.

Today I pushed the AVR (ATmega32) up to its maximum of 16MHz.
So I now need 4 nops not two. So I did that.. and the LCD doesn't work
reliably. Suspecting the problem, I went straight to the generated
assembly, and horror, my 4 nop statements have disappeared !

I made a few trials. It appears that up to and including 3 nop
statements, GCC leaves them alone. But if I put 4 of them, it removes
them all ! 

Any way to instruct GCC to leave my 4 nops ?

Am using avr-gcc 4.3.2


Regards,

--
Vince


___
AVR-GCC-list mailing list
AVR-GCC-list@nongnu.org
http://lists.nongnu.org/mailman/listinfo/avr-gcc-list