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

Syntax Help

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Sophi



Joined: 14 Jun 2005
Posts: 64

View user's profile Send private message

Syntax Help
PostPosted: Tue Jun 14, 2005 10:12 am     Reply with quote

Hi-
I want to send a 16-bit command to a D/A from a PIC. The D/A accepts data MSB first.
My line of code to do this looks like this:
output_bit (PIN_B1, shift_left (valve, 1,0)
- the 1 and 0 are borrowed from another code and I don't know what it means.
Any info on what this syntax means and/or suggestions for coding this?
Thanks-
Sophi
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Jun 14, 2005 11:02 am     Reply with quote

Go here and get the current compiler manual.
http://www.ccsinfo.com/download.shtml

Or look for the CCS Help file in this folder:
c:\Program Files\Picc
You will find CCSC.HLP and CCSC.CHM.
bfemmel



Joined: 18 Jul 2004
Posts: 40
Location: San Carlos, CA.

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

PostPosted: Tue Jun 14, 2005 1:48 pm     Reply with quote

Sophi,

You can also use the SPI to write the data out to the DAC. I do that with a 12 bit DAC sending the high byte first and then the low byte. Here is my subroutine to do that.
Code:

void SetDacVoltage(unsigned int16 voltage) {
   output_low (DAC_LD);             // Pulling this bit low allows new numbers to be accepted
   spi_write(MAKE8(voltage,1));     // Write out high byte first
   spi_write(MAKE8(voltage,0));     // Write out low byte next
   output_high(DAC_LD);             // Pull bit back high to latch data into device
}

I use an 18F6520 and this code has worked fine with the 12bit DAC, it should work just fine with the 16 bit DAC.

- Bruce
Sophi



Joined: 14 Jun 2005
Posts: 64

View user's profile Send private message

PostPosted: Tue Jun 14, 2005 5:25 pm     Reply with quote

Thanks to PCM programmer for the link to the manual. All is well.
Thanks also to Bruce for the suggestion and the code.
Sophi
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
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