0
Offline
Newbie
Karma: 0
Posts: 12
Arduino rocks
|
 |
« on: February 23, 2008, 04:30:06 pm » |
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.htmlIt 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
God Member
Karma: 0
Posts: 593
|
 |
« Reply #1 on: February 23, 2008, 05:40:27 pm » |
I cant see anyone giving up GCC.  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
Faraday Member
Karma: 6
Posts: 6226
Have fun!
|
 |
« Reply #2 on: February 23, 2008, 05:41:56 pm » |
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
Newbie
Karma: 0
Posts: 12
Arduino rocks
|
 |
« Reply #3 on: February 23, 2008, 07:30:20 pm » |
Hi mem, Thanks, you are absolutely right - it did say 'Arduino C' at one time - now it does again - just corrected.  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. 
|
|
|
|
|
Logged
|
|
|
|
|
0
Offline
Newbie
Karma: 0
Posts: 12
Arduino rocks
|
 |
« Reply #4 on: February 23, 2008, 07:40:45 pm » |
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
God Member
Karma: 0
Posts: 593
|
 |
« Reply #5 on: February 23, 2008, 07:49:21 pm » |
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
Newbie
Karma: 0
Posts: 12
Arduino rocks
|
 |
« Reply #6 on: February 23, 2008, 08:02:16 pm » |
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
God Member
Karma: 0
Posts: 593
|
 |
« Reply #7 on: February 23, 2008, 08:41:22 pm » |
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.  Those two are defined in wiring_private.h and are pretty simple. #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
Newbie
Karma: 0
Posts: 12
Arduino rocks
|
 |
« Reply #8 on: February 25, 2008, 01:44:40 pm » |
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 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
God Member
Karma: 0
Posts: 593
|
 |
« Reply #9 on: February 25, 2008, 03:35:07 pm » |
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. 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
Jr. Member
Karma: 0
Posts: 95
Arduino newbie
|
 |
« Reply #10 on: February 26, 2008, 06:25:40 am » |
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
God Member
Karma: 0
Posts: 593
|
 |
« Reply #11 on: February 26, 2008, 03:48:02 pm » |
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
Faraday Member
Karma: 6
Posts: 2504
|
 |
« Reply #12 on: February 26, 2008, 04:10:00 pm » |
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
Jr. Member
Karma: 0
Posts: 73
Arduino rocks
|
 |
« Reply #13 on: March 10, 2008, 10:34:23 pm » |
I love the Arduino environment.
|
|
|
|
|
Logged
|
|
|
|
|
|