OT but I’ve just got into microcontrollers for the first time in the last week via an Arduino Uno. I’m absolutely in love with it and I now need to go a bit deeper (I’m working on a synth). I get a lot of the concepts like the registers to control the timers / interrupts but I’ve found a good guide to be lacking. I haven’t seen a list anywhere of all the available registers and what the bits do. I get that it’s different for different chips but I thought the info for more common ones (like the ATMega328) would be easier to come by.
If you want results rather than a learning experience, consider upgrading to a Teensy 3.2 and Teensy Audio Adapter. The Teensy (ARM Cortex M4) has the power and I/O to produce quality audio. It still uses the Arduino IDE and APIs, and the audio library gives you a high level toolkit.
I have implemented several soft synths on the Teensy, both with and without the audio library. It works.
Thanks for the tip. I’d seen Teensy mentioned in my travels but didn’t look any further. At the moment I care about the learning over the quality but I’ll check this out once I understand the space better.
The manufacturer website is where you usually want to go to find the documentation. The product datasheet will specify the peripherals and register set for the chip you're looking at, including a description of each register and the fields within them. Some companies have a different name for this document. E.g. ST usually define their registers in a Reference Manual.
To add, ST has a 'datasheet' and a 'reference manual' for each chip and chip family. The datasheet is usually under 200 pages and is focused more on electrical information and is focused on a few chips. The ST reference manuals are generally over 1000 pages and cover all of the software/register information for a family of parts.
You will want to code on the avr directly. The problem with audio processing on arduino is that there is a 1ms system tick that is higher priority than user code. It causes audio signals to sound scratchy, even a solid tone because the arduino pwm is all interrupt driven.
Interesting. For my first experiments I don’t really mind - will just be happy to get sane output driven by midi!
From what I gather, the technique is to change the PWM in an interrupt continuously to match the amplitude of your output wave. During that 1ms, what happens? Does the PWM still output a regular wave but I can’t adjust it? Or does the PWM wave itself stop?
The first problem with doing this in arduino is that the pwm is interrupt based. So that limits the frequency. There is a tone library that can generate a pwm for a specific tone, but these are interrupt pwms and it cannot work correctly with the 1ms tick causing jitter. I see arduino projects every now and then as a consultant and one of them was to generate tones. It sounds scratchy out of the box if all you do is generate a tone. Had to modify arduino core for it to use hardware pwm. Why didn't they use hardware pwm in the first place? Its because they needed pwm to work on any pin not just the 8 or so pwm pins, and they sacrificed a lot of performance to do it. I love arduino for inventors to get something running, but for coders and engineers, you guys are smart just program on AVR in C, or better yet program on a modern arm cortex in C. If you want a blazing fast mcu check out the FRDM-K64F, this is 32 bits 150MHz vs the AVR's 8 bits and 20MHz, plus it has a nice DAC so you won't have to do pwm modulation, not to mention 256kb ram vs the arduino's 8kb.
Any hints on where to look?