Midi 2 VCO converter, first steps. |
DAC
The DAC part can be seen to the right in the schematic. I've tested it out using an Aardvark I2C host adapter I borrowed from work, and it seems to work fine. When I choose the voltage reference, I thought that the 4.096V reference would fit well with a 12 bit DAC (0.001V/bit), but the DAC isn't perfectly rail to rail, so I effectively get a 0-4V DAC. I might just upgrade this with a 5V reference instead. Ideally it would be better with a higher voltage DAC since I intend to build a 1 octave/V VCO, and 0-4 V only gives me 3 octaves (4 if I upgrade to 5 V).
Microcontroller
Microcontroller is seen to the left in the schematic. The symbol for the PIC doesn't have the correct pin descriptions, but is generally the same as the one I use, regarding supply, IO's and programming pins. I made a hello world program that blinks an LED using interrupts. This may seems simple, but it gives me a starting point where I know that IO's, clocks and interrupts are working.
Next thing will be getting some UART communication working, and connecting it to the I2C bus.
Some Hello World!-action. Microcontroller to the right, DAC and reference to the left. |
Microcontroller source code
1: //Hello world with LED connected to RA0 on a PIC12F1822
2:
3: #include <xc.h>
4:
5: //Configuration bits
6: #pragma config WDTE=OFF, PWRTE = OFF, MCLRE=OFF, BOREN=OFF, FCMEN=OFF, CLKOUTEN = OFF, IESO=OFF, FOSC=INTOSC, CPD=OFF, LVP = ON, BORV = 0
7:
8:
9: void main()
10: {
11: //0 Internal oscillator, 3 <fosc> on, 6-4 31kHz
12: OSCCON = 0b00000000;
13:
14: //Interrupt controller
15: //5 Timer0 overflow interrupt enabled
16: //7 Global interrupt enabled
17: INTCON = 0b10100000;
18:
19: //Timer0
20: TMR0 = 0x00;
21:
22: //Option Register
23: //2-0 Prescaler 1:4
24: //3 prescaler assigned to Timer0
25: //4 timer edge, high to low
26: OPTION_REG = 0b11010001;
27:
28: //TRISA
29: //All A I/O's are set as outputs
30: TRISA = 0b0000000;
31:
32: //PORTA
33: //RA0 is set
34: PORTA = 0b00000001;
35:
36: //Loop forever, interrupts when Timer0 overflows
37: while(1)
38: {
39: }
40:
41: }
42:
43: //Interrupt routine
44: interrupt void isr (void)
45: {
46: //Ghost register of PORTA
47: int GPORTA;
48:
49: //Read latch A into ghost register
50: GPORTA = LATA;
51: //Toggle bit 0
52: GPORTA = GPORTA^(1<<0);
53: //Write back into port register
54: PORTA = GPORTA;
55:
56: //Clear interrupt flag
57: TMR0IF = 0;
58:
59: return;
60: }
61: