View previous topic :: View next topic |
Author |
Message |
Foppie
Joined: 16 Sep 2005 Posts: 138 Location: The Netherlands
|
MCP4922 DAC not working |
Posted: Mon Oct 24, 2005 2:44 am |
|
|
Hi,
I am trying to get a MCP4922 Digital-analog Convertor working but I can't seem to make it running. I previously used a AD5312 DAC chip and that worked perfectly. But the hardware designer changed parts. I rewrote the working code for the MCP4922 chip but it didn't work. I could see all the incoming signals with a osilloscope and they are as programmed. I use (much) more delay then the datasheet required. All input pins have the expected input, but no output is measured on the output pins.
Then I started coding from scratch but teh same problem re-appeared.
At last I tried the built-in hardware SPI functions of CCS, but again the input seems to be right while no output is measured.
I already tried 2 different MCP4922 chips, but they both give the same results.
Can someone give me some tips on how to solve my problem?
Jos |
|
|
Mark
Joined: 07 Sep 2003 Posts: 2838 Location: Atlanta, GA
|
|
Posted: Mon Oct 24, 2005 11:24 am |
|
|
From the amount of information that you have given, here is the best that we can give you:
Either your code is bad or the hardware is. |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Mon Oct 24, 2005 11:46 am |
|
|
Have you search the forum for sample code ?
http://www.ccsinfo.com/forum/search.php
Search for MCP4922 and also for MCP4921. There's code there, and
also information on what SPI mode to use.
Also search http://www.google.com for these strings:
MCP4922 int char
and
MCP4921 int char
You can find one hit with sample code with each search string.
Compare it to your own code, and see if you've done something wrong. |
|
|
Foppie
Joined: 16 Sep 2005 Posts: 138 Location: The Netherlands
|
|
Posted: Tue Oct 25, 2005 1:44 am |
|
|
I solved the problem, it was software
thanks for the replies |
|
|
sonicdeejay
Joined: 20 Dec 2005 Posts: 112
|
|
Posted: Sun Feb 19, 2006 8:54 am |
|
|
I can't seem to able to find MCP DAC in Singapore... |
|
|
sjbaxter
Joined: 26 Jan 2006 Posts: 141 Location: Cheshire, UK
|
|
Posted: Sun Feb 19, 2006 11:04 am |
|
|
You can get small quantities of the microchip DAC using their online sample service. _________________ Regards,
Simon. |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Sun Feb 19, 2006 3:22 pm |
|
|
Digikey has a Singapore website, and they show the MCP4922 is in stock.
http://sg.digikey.com/
The U.S. website has a minimum order of $25 (US). If you order less
than that, you have to pay a $5 service charge. The Singapore site
is probably similar. |
|
|
Guest
|
|
Posted: Sun Feb 19, 2006 8:19 pm |
|
|
PCM programmer wrote: | Digikey has a Singapore website, and they show the MCP4922 is in stock.
http://sg.digikey.com/
The U.S. website has a minimum order of $25 (US). If you order less
than that, you have to pay a $5 service charge. The Singapore site
is probably similar. |
Is it suit my requirement sir??
I need to output 2 differents digital values (e.g temp1 and temp2) from a PIC..so I don't think i can use i2c as it only cater for 1 output....
I am using PIC18F2525...
|
|
|
The Puma
Joined: 23 Apr 2004 Posts: 227 Location: The Netherlands
|
|
Posted: Mon Nov 05, 2007 11:47 am |
|
|
Please post a working driver for this chip |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Mon Nov 05, 2007 12:01 pm |
|
|
Look in the Drivers directory of your CCS compiler:
Quote: | c:\program files\picc\drivers\mcp4921.c |
If it's not there, then update the compiler or email CCS support and
ask them if they will give it to you. Include your CCS User Reference
number in the email so they know you own the compiler. |
|
|
The Puma
Joined: 23 Apr 2004 Posts: 227 Location: The Netherlands
|
|
Posted: Mon Nov 05, 2007 12:08 pm |
|
|
I have found this file, but it is for the MCP4921
The MCP4922 is dual channel
The code need some changes |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Mon Nov 05, 2007 12:27 pm |
|
|
It's not that hard to change. Just add a channel parameter (0 = A, 1 = B)
and add code to check that parameter and set the channel bit, as shown
in bold below.
Quote: | void write_dac(int8 channel, int16 data) {
BYTE cmd[3];
BYTE i;
cmd[0]=data;
cmd[1]=(data>>8);
cmd[2]=0x03;
if(channel)
cmd[2] |= 0x08;
|
|
|
|
The Puma
Joined: 23 Apr 2004 Posts: 227 Location: The Netherlands
|
|
Posted: Mon Nov 05, 2007 12:40 pm |
|
|
What value must have bit 12,
and how must that be set?
bit 12 SHDN: Output Power Down Control bit
1 = Output Power Down Control bit
0 = Output buffer disabled, Output is high impedance |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Mon Nov 05, 2007 12:48 pm |
|
|
Bits 12-15 of the MCP4922 command word are contained in the lower
4 bits of the 'cmd[2]' variable. CCS sets it to 0x03 with this line of code:
That means that \SHDN and \GA are set = 1. |
|
|
The Puma
Joined: 23 Apr 2004 Posts: 227 Location: The Netherlands
|
|
Posted: Mon Nov 05, 2007 12:59 pm |
|
|
Where can this bit set, or is this not used in sample code?
bit 14 BUF: VREF Input Buffer Control bit
1 = Buffered
0 = Unbuffered
Why is the cmd variable 3 byte long?
The chip use only 16bits
Code: | cmd[0]=data;
cmd[1]=(data>>8);
cmd[2]=0x03; |
@PCM
Please can you explain what this code exactly do,
than can i learn something, and not only copy the code and it works
Code: | for(i=0;i<=23;++i) {
if(i<4||(i>7&&i<12))
shift_left(cmd,3,0);
else {
output_bit(MCP4922_DI,shift_left(cmd,3,0));
|
Last edited by The Puma on Mon Nov 05, 2007 1:06 pm; edited 2 times in total |
|
|
|