Pages: [1]   Go Down
Author Topic: Another Compiler  (Read 1895 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Newbie
*
Karma: 0
Posts: 12
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi,

Not sure which section this should be in - anyway, if you have an open mind this may be of interest:
www.rhombus-tek.com/BC4Arduino.html

It is a free no time limit demo, adapted for the Arduino hardware and includes the equivalents of DigitalRead/Write etc.. Has extensive libraries for LCDs(Char&Graphic)/KeyPads/I2C/SPI/RC5/1-Wire/SWUARTS and more.

David

Logged

Brisbane, Australia
Offline Offline
God Member
*****
Karma: 1
Posts: 593
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I cant see anyone giving up GCC. smiley-wink

By the way if anyone is curious about why the Arduino code compiles bigger than the Bascom code, its because the Arduino does the pin number conversion at run time while the library for Bascom does it at run time.
I believe GCC compiles somewhat smaller than Bascom.
Logged

London
Offline Offline
Tesla Member
***
Karma: 10
Posts: 6250
Have fun!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

That looks interesting, particularly for those more comfortable with Basic than with C.

I do think the statement on the page you linked saying “when controlling I/O Pins runs 25 times faster than 'C'.” is a little misleading. That speed improvement is over the Arduino digitalWrite function. But if maximum performance is required you can get more than a 25 times speed improvement with Arduino C code using direct port manipulation as documented here: http://www.arduino.cc/en/Reference/PortManipulation
« Last Edit: February 23, 2008, 05:42:58 pm by mem » Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 12
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi mem,
Thanks, you are absolutely right - it did say 'Arduino C' at one time - now it does again - just corrected. smiley

Hi Cheater,
Quote 'By the way if anyone is curious about why the Arduino code compiles bigger than the Bascom code, its because the Arduino does the pin number conversion at run time while the library for Bascom does it at run(compile) time.'

I agree - so why not use the same Set/Reset P0-P13 in C and let it also run at assembler speed ?
Thanks for input.  smiley
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 12
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi mem - I failed to respond to >25 - BASCOM is right at the assembler limit using SBI/CBI so 125nS each at 16MHz.
Logged

Brisbane, Australia
Offline Offline
God Member
*****
Karma: 1
Posts: 593
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
I agree - so why not use the same Set/Reset P0-P13 in C and let it also run at assembler speed ?
Its done at runtime to prevent newbie mistakes. Your library doesnt stop them.
For experts its just overhead but we know how to do it fast anyway if we need to.
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 12
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi Cheater,

I know very little about C, and am genuinely interested in the fastest & most simple C code for:
Set Out13
Reset Out13

Thanks
Logged

Brisbane, Australia
Offline Offline
God Member
*****
Karma: 1
Posts: 593
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Ok pin 13 would be pin 5 on port B on the actual chip.

Fastest way to turn it on is sbi(PORTB, 5) and to turn it of its cbi(PORTB, 5).
Just like assembly. smiley

Those two are defined in wiring_private.h and are pretty simple.
Code:
#ifndef cbi
#define cbi(sfr, bit) (_SFR_BYTE(sfr) &= ~_BV(bit))
#endif
#ifndef sbi
#define sbi(sfr, bit) (_SFR_BYTE(sfr) |= _BV(bit))
#endif
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 12
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi Cheater,
Thanks, that achieves the same speed - but there is the loss of P0-P13 clarity.

I also want to give feedback on your
Quote
By the way if anyone is curious about why the Arduino code compiles bigger than the Bascom code, its because the Arduino does the pin number conversion at run time while the library for Bascom does it at run time.
I substituted sbi(PORTB,5) etc in Blink, so that Arduino would also benefit from the compile-time conversion, but it made little difference.

I even went one stage further and removed 2 redundant likes of code from Blink, so total is now:
sbi(PINB,5);
delay(500);
but still 1085 bytes - so will not waste any more time on it - but thanks.
Logged

Brisbane, Australia
Offline Offline
God Member
*****
Karma: 1
Posts: 593
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Thanks, that achieves the same speed - but there is the loss of P0-P13 clarity.
It is possible to do what you've done and just make them 'aliases' and convert them to the proper names before compiling.
I consider that a really ugly thing to do however.

Quote
I even went one stage further and removed 2 redundant likes of code from Blink, so total is now:
sbi(PINB,5);
delay(500);
but still 1085 bytes - so will not waste any more time on it - but thanks.
Thats because your compiling against the Arduino libraries. They are always included.
If you compile it separately (with a Makefile) then there is no overhead.
Logged

New England
Offline Offline
Jr. Member
**
Karma: 0
Posts: 95
Arduino newbie
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Thats because your compiling against the Arduino libraries. They are always included.
If you compile it separately (with a Makefile) then there is no overhead.
Is that a difference in "cc -o whatever pins_arduino.o HardwareSerial.o ..." vs "cc -o whatever -larduino" (where libarduino.a is the output of "ar <er, something...> pins_arduino.o HardwareSerial.o ...")?
Logged

Brisbane, Australia
Offline Offline
God Member
*****
Karma: 1
Posts: 593
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Quote
Is that a difference in "cc -o whatever pins_arduino.o HardwareSerial.o ..." vs "cc -o whatever -larduino" (where libarduino.a is the output of "ar <er, something...> pins_arduino.o HardwareSerial.o ...")?
I think there is a difference but I'm not sure.
Logged

0
Offline Offline
Faraday Member
**
Karma: 8
Posts: 2526
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Is that a difference in "cc -o whatever pins_arduino.o HardwareSerial.o ..." vs "cc -o whatever -larduino" (where libarduino.a is the output of "ar <er, something...> pins_arduino.o HardwareSerial.o ...")?

Yes.  Linking against all the .o files crams them all together, just like you ask.  Making a library and linking against -larduino extracts the code for the functions you use (not the whole thing) and merges only the needed code with the executable.

-j

Logged

USA
Offline Offline
Jr. Member
**
Karma: 0
Posts: 73
Arduino rocks
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I love the Arduino environment.
Logged


Pages: [1]   Go Up
Jump to: