chipKIT® Development Platform

Inspired by Arduino™

MCP49xx - the need for speed

Created Sat, 06 Dec 2014 21:48:05 +0000 by madias


Sat, 06 Dec 2014 21:48:05 +0000

Hello, I was fooling around with some MCP49xx DAC's getting out the maximum speed (without phase accumulator). Any suggestions or improvements for my code?

Thank you! Matthias

/* mcp49xx speed demo
 * Used DAC: MCP4922 -> 12bit dual DAC
 Bits 0 to 11 are the 12 bits of the output value; bit 15 is an output selector 
 (unused on the MPC4921); bit 14 controls the input buffer; bit 13 controls an inbuilt 
 output amplifier; and bit 12 can shutdown the DAC. 
 Results: PIC32MX250F128@40mhz, ~152Hz (12 bit deep) 
#include <DSPI.h>
int value =0;
unsigned int commando=0b0111000000000000; // mcp49xx start commando channel#1,buffer on, amp on
void setup()
    LATBCLR  = 0x1;     // RB0 Off
    TRISBCLR = 0x1;     // RB0 as output
void loop()
    while(1) // gives some extra Hz
   LATBCLR  = 0x1; //cs LOW
  LATBSET = 0x1; // cs HIGH


Sat, 06 Dec 2014 22:02:30 +0000

You could get more speed out of it using DMA to directly drive the SPI data register...


Sat, 06 Dec 2014 22:28:41 +0000

programming DMA is beyond my acknowledge at this time, but it's on the todo-list for month. Sadly there are no easy tutorials about DMA in general (understand me right, I know how it works, but I've no plan how to implement it). I've done some estimated calculations: highest SPI rate for MCP49xx: 20mhz so: 20.000 / 4096 (current data) / 16 (command) = about 305Hz, much too slow for any (DDS) audio applications, without phase accumulator. My plans for the pic32mx250 are to substitute the Atmega328 of my 4-voice hybrid synth (4 "DCO's" (DDS) and analog multimode analog filters + VCA based on V(SSM)2164). The major improvement is the more SRAM with 32kb you can get really complex wavetables without further hardware. On my prototype I used 8-bit dual parallel DAC's (TLC7528CN) now I'm thinking about 12bit, maybe I choose the banal method with (high frequency) PWM and some filtering...


Sat, 06 Dec 2014 22:33:28 +0000

There's always the option of using the I2S interface the MX250 has, and driving a CODEC chip for full 16-bit ;)


Sat, 06 Dec 2014 23:06:57 +0000

...but where is the fun about that? ;) hehe, I found some obligate TDA1543's on aliexpress for about 0.50 Euro/pcs (min 10pcs)...damn, I hate internet shopping.