Hi all,
Last year I did basic C++ at Uni and we had to buy an 'ousb'. Apart from turning LEDs on and off via a char value sent through a pipe we didn't use it very much. (Links about it at the end)
Its powered by an ATMEGA32 an I was wondering if it could be made to work like an Arduino, while I wait for my Arduino Mega 2560 to be sent?
Well, there is a company in Thailand the produces an ATmega32 Arduino clone so it's not a huge stretch. A first step would be to download "Software Support" from their page:
The 12MHz clock rate will be a problem. Anything that relies on 'delayMicroseconds()' only works properly at 8 or 16 MHz. Also any value of MHz that doesn't divide into 64 evenly will get incorrect values for delay(). You should change the crystal to 8 MHz.
The "Software Support" from Thailand doesn't include a bootloader. Maybe the ATmegaBOOT.hex bootloader will work. Maybe it won't. I suspect they just didn't think users would need the ability to burn a fresh ATmega32 bootloader so I suspect the bootloader and fuse settings they provide are just left over from whatever boards.txt entry they cloned:
Other entries in there may be bogus as well. I'd suspect the maximum sketch size value. Also, the f_cpu will need to match your new 8 MHz crystal.
The Software Support provides a new ATmega32 compatible arduino core. Looks like they may have intended you to OVERWRITE the existing core. Probably better to save the new core as 'arduino32' under /hardware/arduino32/cores/arduino32
So the short version of that is not very easily and not without new parts.
I'll leave it as is and save the money for parts for the Arduino. I'll use it for just playing around with while I wait, the main concepts will transfer across to the Arduino so I wont be wasting my time.
Thanks johnwasser that was very insightful and in depth.
If you want to still use the USB port you couldn't change the crystal to 8MHz, it needs to either remain at 12MHz, or you could the 16MHz version of V-USB.
It looks like OUSB used the software-driven (VUSB) code to connectivity, making it somewhat similar to the recent tiny85 systems that have been shipped (digiSpark, Gemma, Trinket.) That probably means that it COULD be used under Arduino, given some "Small amount of programming" (and perhaps that 16MHz crystal upgrade.)
Or it might be easier to run existing non-USB arduino cores (mega32 has been mentioned before), with the addition of an external USB/Serial cable.
I'd write that another way, just for the same of optimisation:
void ousb_delay(unsigned long t)
{
// multiply t by 3/4 to compensate for 12MHz clock when expecting 16MHz
t += (t<<1); //gets rid of slow multiplication - t*3 = t + (2*t) = t + (t << 1)
t >>= 2; //this would have been optimised in anyway.
delay(t);
}