CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

MCP4922 DAC not working
Goto page 1, 2  Next
 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Foppie



Joined: 16 Sep 2005
Posts: 138
Location: The Netherlands

View user's profile Send private message Send e-mail Visit poster's website MSN Messenger

MCP4922 DAC not working
PostPosted: Mon Oct 24, 2005 2:44 am     Reply with quote

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

View user's profile Send private message Send e-mail

PostPosted: Mon Oct 24, 2005 11:24 am     Reply with quote

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

View user's profile Send private message

PostPosted: Mon Oct 24, 2005 11:46 am     Reply with quote

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

View user's profile Send private message Send e-mail Visit poster's website MSN Messenger

PostPosted: Tue Oct 25, 2005 1:44 am     Reply with quote

I solved the problem, it was software Embarassed

thanks for the replies
sonicdeejay



Joined: 20 Dec 2005
Posts: 112

View user's profile Send private message

PostPosted: Sun Feb 19, 2006 8:54 am     Reply with quote

I can't seem to able to find MCP DAC in Singapore... Sad
sjbaxter



Joined: 26 Jan 2006
Posts: 141
Location: Cheshire, UK

View user's profile Send private message Visit poster's website

PostPosted: Sun Feb 19, 2006 11:04 am     Reply with quote

You can get small quantities of the microchip DAC using their online sample service.
_________________
Regards,
Simon.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sun Feb 19, 2006 3:22 pm     Reply with quote

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








PostPosted: Sun Feb 19, 2006 8:19 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Mon Nov 05, 2007 11:47 am     Reply with quote

Please post a working driver for this chip
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Nov 05, 2007 12:01 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Mon Nov 05, 2007 12:08 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Mon Nov 05, 2007 12:27 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Mon Nov 05, 2007 12:40 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Mon Nov 05, 2007 12:48 pm     Reply with quote

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:
Code:
cmd[2]=0x03; 

That means that \SHDN and \GA are set = 1.
The Puma



Joined: 23 Apr 2004
Posts: 227
Location: The Netherlands

View user's profile Send private message

PostPosted: Mon Nov 05, 2007 12:59 pm     Reply with quote

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
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group