Mozzi
version 2015-05-11-20:23
sound synthesis library for Arduino
All
Classes
Functions
Typedefs
Groups
AudioConfigHiSpeed14bitPwm.h
1
#ifndef AUDIOCONFIGHISPEED14BITPWM_H
2
#define AUDIOCONFIGHISPEED14BITPWM_H
3
4
/*
5
14 bit sound at 16384 Hz and 125kHz pwm rate
6
Timer 1: PWM 125kHz
7
Timer 2: called at AUDIO_RATE 16384 Hz, setting Timer1 pwm levels
8
Output on Timer1, low uint8_t on Pin 10, and high uint8_t on Pin 9 (on 328 based Arduino boards)
9
Add signals through a 3.9k resistor on high uint8_t pin and 499k resistor on low uint8_t pin.
10
Use 0.5% resistors or select the most accurate from a batch.
11
As discussed on http://www.openmusiclabs.com/learning/digital/pwm-dac/dual-pwm-circuits/
12
Also, there are higher quality output circuits are on the site.
13
14
Boards, pins and resistor positions are documented in MozziGuts.h
15
*/
16
17
/* PWM carrier frequency, for HIFI this should be well out of hearing range, about 5 times the nyquist frequency if possible. */
18
#define PWM_RATE 125000
19
// following doesn't play nice
20
//#define PWM_RATE 65536 // count will be 244 (7+ bits) on each pin = 14+ bits
21
22
23
// pins defined in TimerOne/config/known_16bit_timers.h
24
#define AUDIO_CHANNEL_1_highByte_PIN TIMER1_A_PIN // 3.9k resistor
25
#define AUDIO_CHANNEL_1_lowByte_PIN TIMER1_B_PIN // 1 M resistor
26
#define AUDIO_CHANNEL_1_highByte_REGISTER OCR1AL
27
#define AUDIO_CHANNEL_1_lowByte_REGISTER OCR1BL
28
29
/* Used internally to put the 0-biased generated audio into the right range for PWM output.*/
30
// 14 bit
31
#define AUDIO_BIAS ((unsigned int) 0x2000)
32
33
34
#endif // #ifndef AUDIOCONFIGHISPEED14BITPWM_H
35
AudioConfigHiSpeed14bitPwm.h
Generated on Mon May 11 2015 20:24:02 for Mozzi by
1.8.7