Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 19:10 16 Sep 2026 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : PicoMite: MCP4922 DAC on SPI

Author Message
Calli
Regular Member

Joined: 20/10/2021
Location: Germany
Posts: 74
Posted: 02:57pm 22 Dec 2021
Copy link to clipboard 
Print this post

I used this DAC before and think it is a nice chip.

Here is some code which works for me and might get you started.


' MCP4922 Dual 12bit DAC
SetPin GP2,GP3,GP4,SPI

SetPin GP6, DOUT
Pin(GP6) = 1

SPI open 4000000,0,16

Do
For a% = 0 To 4096-8 Step 64

' CS Down (LOW Active)
Pin(GP6)=0

'  DACn Write Buffer Gain_ Shutdown_
'           DWBGS
junk = SPI(&B0111000000000000 + a%) ' 1st DAC
Pin(GP6)=1

Pin(GP6)=0
junk = SPI(&B1111000000000000 + a%) ' 2nd DAC

' CS
Pin(GP6)=1

'Print a%
'Pause 300

Next a%
Loop

SPI CLose


Datasheet:
https://www.mouser.de/datasheet/2/268/21897a-70809.pdf

Be sure to get the active LOW-Pins LDAC_ and SHDN_ right, LDAC_ to LOW/GND will trigger the conversion every time the CS_ is rised, so we can save one Pin on the Picomite. Tie SHDN_to VDD to have the chip work.

Cheers,
Carsten
 
Tinine
Guru

Joined: 30/03/2016
Location: United Kingdom
Posts: 1646
Posted: 07:32pm 22 Dec 2021
Copy link to clipboard 
Print this post

Appreciated but can I suggest somewhere that it won't get lost?
 
Calli
Regular Member

Joined: 20/10/2021
Location: Germany
Posts: 74
Posted: 11:49am 29 Dec 2021
Copy link to clipboard 
Print this post

  Tinine said  Appreciated but can I suggest somewhere that it won't get lost?


http://www.fruitoftheshed.com/MMBasic.PicoMite-MCP4922-DAC-on-SPI.ashx

C!
 
twofingers

Guru

Joined: 02/06/2014
Location: Germany
Posts: 1769
Posted: 12:20pm 29 Dec 2021
Copy link to clipboard 
Print this post

Thanks Carsten!

FYI something similar from Peter (matherp): Micromite MK2: MCP4822 DAC
Best regards
Michael

BTW: Micromite MK2:MCP342x i2c ADCs
‚My name is Ozymandias, king of kings
Look on my works, ye Mighty, and despair!‘
Nothing beside remains. Round the decay
Of that colossal wreck, boundless and bare
The lone and ...
 
Print this page


To reply to this topic, you need to log in.

The Back Shed's forum code is written, and hosted, in Australia.
© JAQ Software 2026