Go Down

Topic: Convert SID Emulator to Arduino sketch (Read 732 times) previous topic - next topic

xiphoid

Jan 26, 2008, 04:26 am Last Edit: Jan 26, 2008, 04:26 am by xiphoid Reason: 1
Hello,

The SID emulator code available at http://www.roboterclub-freiburg.de/atmega_sound/atmegaSID.html (specifically, the file SidSource/chAtmega8SID.c) appears to be a file that has to be written directly to the chip (rather than uploaded as an Arduino sketch).

Is it possible and advisable to convert it into an Arduino sketch so that I wouldn't have to get a programmer, etc? Or would doing this be problematic -- memory usage is presumably not a problem for this code... but do Arduino sketches run any slower than this more "native" approach?

Most importantly -- has anyone already converted this SID emulator into an Arduino sketch?

Thanks!

mem

#1
Jan 26, 2008, 08:46 am Last Edit: Jan 26, 2008, 08:51 am by mem Reason: 1
I haven't done it but a look a the code indicates that the following would need to be done:

Change int main(void)  to void loop(void) and remove the outer while loop
Move the initialisation code at the start of main to the setup function, see below
Change void Init(void) to void setup(void)
Remove the call to Init in main (now renamed to loop)
rename void delay(uint16_t n) to void Delay(uint16_t n)
Rename calls to delay to Delay (I think there is only one, in blink_led())

And probably some other stuff I may have missed, but it seems feasable, and a fun project if you are so inclined.

But I would do a search first to see if its already been ported or if there are more capable sound libraries.

follower

Hi,

My understanding is that once an Arduino sketch is compiled there's no difference between that and a C program compiled from the command line--they both produce ".hex" files that need to be put on a chip.

There are two ways a ".hex" file can be put onto the chip:
  • Uploaded via a "bootloader" installed on the chip--this is how the Arduino usually works--using the serial pins.

  • Programmed onto the chip using In-System-Programming using the ISP pins.
With that in mind:

Quote
The SID emulator code available at http://www.roboterclub-freiburg.de/atmega_sound/atmegaSID.html (specifically, the file SidSource/chAtmega8SID.c) appears to be a file that has to be written directly to the chip (rather than uploaded as an Arduino sketch).

First, you would need to compile the code and produce a ".hex" file from it.

Quote
Is it possible and advisable to convert it into an Arduino sketch so that I wouldn't have to get a programmer, etc?

Assuming it fits in the available space on the Arduino board (~14KB--which is the ATMega168 standard code space size less the boot loader) you can upload from the command line using avrdude as used by Arduino.

Quote
Arduino sketches run any slower than this more "native" approach?

Arduino sketches aren't interpreted--they're compiled from the C/C++ code they really are--so they would run at the same speed. (Okay, so there may be a small amount of overhead due to some implementation issues but it's probably negligible.)

Quote
Most importantly -- has anyone already converted this SID emulator into an Arduino sketch?

If all you want to do is "use" it, you may not need to convert it into a sketch first. If you wanted to integrate it as a library into an Arduino sketch then you might not need to convert it either.

The developer seems to be "Arduino-friendly" (given the references on the page) so it might be worth discussing it with him. (From what I see on the page it might be possible--assuming no memory issues--to upload the software to one Arduino board and control it over serial from another board.)

--Phil.

xiphoid

Thank you both for the very helpful replies! I will report back what ends up happening!!


Go Up