Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
projects:generator [2015/03/22 21:55] – external edit 127.0.0.1projects:generator [2017/03/07 05:57] (current) – [Schematic] darron
Line 1: Line 1:
-==== dsPIC tone generator ====+==== dsPIC/PIC32 tone generator ====
 <wrap right> <wrap right>
 {{:projects:generator:gen.jpg?200}} {{:projects:generator:gen.jpg?200}}
 </wrap> </wrap>
  
-This is a  project for the dsPIC33FJ128GP802 acting as a tone generator connected to a [[:boards:rpi|Raspberry Pi]].+This is a  project for the dsPIC33FJ128GP802 or PIC32MX150F128B acting as a tone generator connected to a [[:boards:rpi|Raspberry Pi]].
  
 Four separate tones may be generated simultaneously from five different waves and each tone can be any audible frequency. Four separate tones may be generated simultaneously from five different waves and each tone can be any audible frequency.
Line 11: Line 11:
  
 This project is under development and certain aspects may change and features added or removed at any time. This project is under development and certain aspects may change and features added or removed at any time.
 +
 === Waves === === Waves ===
  
Line 26: Line 27:
 === Schematic === === Schematic ===
  
-This is the bare minimum layout required for this project. We will use a [[:boards:rpi|RPi]] for communication and ICSP.+This is the bare minimum layout required for this project using the dsPIC with integrated audio DAC. We use a [[:boards:rpi|RPi]] for communication and ICSP.
  
 {{:projects:generator:generator.png?200}} {{:projects:generator:generator.png?200}}
 +
 +For PIC32 an external audio DAC is required. Only the CS4334K and PT8211 are supported
 +at present and are selected at compile time. Connection to either device is as follows.
 +
 +<columns 50% 50% ->
 +<code>
 +CS4334K WITH Vcc = 5V.
 +
 +PIC32MX150   CS4334K         COMMENT
 +----------   -------         -------
 +PIN 15 RPB6  PIN 4 MCLK      128X OVERSAMPLING CLOCK
 +PIN 16 RPB7  PIN 3 LRCK      SAMPLE RATE LEFT/RIGHT CLOCK
 +PIN 17 RPB8  PIN 1 SDATA     SERIAL DATA INPUT
 +PIN 18 RPB9  PIN 2 DEM/SCLK  DE-EMPHASIS FILTER OFF/ON
 +PIN 25 SCK1                  UNUSED
 +</code>
 +
 +</columns>
 +
 +<columns 50% 50% ->
 +
 +<code>
 +PT8211 WITH Vdd = 5V.
 +
 +PIC32MX150   PT8211          COMMENT
 +----------   -------         -------
 +PIN 15 RPB6                  UNUSED
 +PIN 16 RPB7  PIN 2 WS        SAMPLE RATE LEFT/RIGHT CLOCK
 +PIN 17 RPB8  PIN 3 SDATA     SERIAL DATA INPUT
 +PIN 18 RPB9                  UNUSED
 +PIN 25 SCK1  PIN 1 BCK       SERIAL BIT CLOCK
 +</code>
 +
 +</columns>
 +
 +The CS4334K is a far superior device, but the PT8211 is incredibly cheap (15p each).
  
 === Firmware === === Firmware ===
  
-First install a working [[:tools:xc16|XC16]] compiler.+For dSPIC First install a working [[:tools:xc16|XC16]] compiler, for PIC32, install [[:tools:xc32|XC32]].
  
-Now build the dsPIC application.+Now build the dsPIC/PIC32 applications.
 <code> <code>
 hg clone http://hg.kewl.org/pub/generator hg clone http://hg.kewl.org/pub/generator
-cd generator+cd generator/src
 make make
 </code> </code>
  
 [[:projects:pickle|Pickle]] must be installed and configured and when ready we can write the firmware. [[:projects:pickle|Pickle]] must be installed and configured and when ready we can write the firmware.
 +
 +Eg.
 <code> <code>
-p24 lvp program dac/dac.hex+p24 lvp program dspic.hex
 </code> </code>
  
Line 68: Line 107:
 | /      | The accumulator low word is transferred to the voice volume word                               | | /      | The accumulator low word is transferred to the voice volume word                               |
 | %      | The accumulator low word is transferred to the voice square wave duty word                     | | %      | The accumulator low word is transferred to the voice square wave duty word                     |
-| @      | The accumulated is evaluated as the voice ADSR envelope                                        |+| @      | The accumulater low word is transferred to the voice ADSR envelope generator                   |
 | !      | Trigger the voice ADSR envelope                                                                | | !      | Trigger the voice ADSR envelope                                                                |
 | >      | The accumulator low nibble is transferred to the voice selection byte                          | | >      | The accumulator low nibble is transferred to the voice selection byte                          |
Line 105: Line 144:
 === Resources === === Resources ===
 [[http://en.wikipedia.org/wiki/Numerically_controlled_oscillator|NCO]] [[http://en.wikipedia.org/wiki/Numerically_controlled_oscillator|NCO]]
 +