Audino V5 in IDE 1.0 Possible Solution

Hi,
For anyone trying to get the Audino project to run and finding that only pot 4 changes anything, you need to add the volatile keyword to the variable declarations. My assumption is that a new compiler optimisation in Arduino 1.0 is replacing the variables inside the ISRs with local (register based) copies which are not updated by the analogReads in the main loop.

I have left a suggestion to this effect on the Audino project page for the project owners.

I am just breadboarding the project at the moment with a mismatch of components, once I have a suitable set up to confirm the results I will post my suggestion for an Arduino 1.0 compatible version, in the meantime you can add volatile to all of the global variables as such -

volatile uint16_t syncPhaseAcc;
volatile uint16_t syncPhaseInc;
volatile uint16_t grainPhaseAcc;
volatile uint16_t grainPhaseInc;
volatile uint16_t grainAmp;
volatile uint8_t grainDecay;
volatile uint16_t grain2PhaseAcc;
volatile uint16_t grain2PhaseInc;
volatile uint16_t grain2Amp;
volatile uint8_t grain2Decay;

Note - The volatile keyword is not needed in every case however I do not have the resources to confirm which at the moment.

EDIT - for clarity.

Duane B

rcarduino.blogspot.com

For anyone trying to get the Audino project to run and finding that only pot 4 changes anything,

I do not understand the problem.

Why should we make all global vars volatile?
Vars need only be volatile to prevent the compiler from optimizing them with registers.
Typically used in synchronization issues between a main program and ISR's (and probably some other cases).

Hopefully he means: "variables which are shared between an ISR and the main code".

That is all that needs to be made volatile and it was always thus.

Hi,
Are either of you using Auduino V5 with IDE 1.0 ? thats 'Auduino' not 'Arduino'

Are either of you using Auduino with any version of the IDE ?

If not, you can download the code from - Google Code Archive - Long-term storage for Google Code Project Hosting.

You will see that there are a set of global variables that set the synth parameters in loop.

These same global variables are used in a timer driven ISR to create the synth output.

The code does not work correctly for me as it is presented on the site, the analogue inputs have no effect. On reading through the code it looked quite likely that the global variables are being optimized in some fashion that the copies in loop are not updating the copies in the ISR. On this basis I added volatile to the variable declarations and now all analogInputs are correctly controlling the synth parameters.

I do not understand the problem.

Why should we make all global vars volatile?
Vars need only be volatile to prevent the compiler from optimizing them with registers.
Typically used in synchronization issues between a main program and ISR's (and probably some other cases).

Indeed.

That is all that needs to be made volatile and it was always thus.

While it may have always been so, it is not so in the Audino code which is my I am suggesting this fix.

Duane B

rcarduino.blogspot.com

I would expect these variables to be needed as volatile:

syncPhaseInc
grainPhaseInc
grainDecay
grain2PhaseInc
grain2Decay

That is because they are used in both loop and the ISR.

Can you name another variable that needs to be made volatile for it to work?

You are correct that the code needs those (above), and therefore the code on the site is wrong. But that is simply because those ones are the ones that are shared between inside an ISR and outside an ISR.

Hi,
From my original post -

Note - The volatile keyword is not needed in every case however I do not have the resources to confirm which at the moment.

I assume that its just these five but would like to do a quick test this evening before posting a final copy of the updated code.

Duane B

rcarduino.blogspot.com

This isn't what I was planning, but I have been out and accidentally bought a nice rugged clear topped enclosure. It was way too expensive but seeing the clear top I couldn't get away from the idea of combining the Audino with an LED Chaser/visualizer of some sort. The Audino only uses timer2 so that leaves me 0 and 1 for PWM, I also picked up some hex drivers and 4017's for chasers.

Duane B

rcarduino.blogspot.com