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 support@ccsinfo.com

Code for ADE7756 ?

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



Joined: 15 Sep 2004
Posts: 5

View user's profile Send private message

Code for ADE7756 ?
PostPosted: Mon Sep 27, 2004 12:01 pm     Reply with quote

Has anybody write code for ADE7756 ?
I have started project power meter and I'm looking for example.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Sep 27, 2004 4:04 pm     Reply with quote

Analog Devices has ASM code for a 16F873 here:
http://www.analog.com/UploadedFiles/Associated_Docs/317740795RMS_CODE.txt
You could translate it to C.

For example, this section of the ASM code sets up the SPI module:
Code:
;---------setup spi port for 7756 communication-------------------
; movlw  B'00000010' ;set up spi as master fos/64 idle state high
  movlw  B'00000001' ;set up spi as master fos/16 idle state high
; movlw  B'00000000' ;set up spi as master fos/4 idle state high
  movwf  SSPCON      ; mov w to spi control register
  movlw  B'00000000'
  bsf    STATUS,5    ;set to bank 1
  movwf  SSPSTAT     ;set up clk edges
  bcf    STATUS,5    ;set to bank 0
; movlw  B'00100000' ;set up spi as master fos/4 idle state high
; movlw  B'00100001' ;set up spi as master fos/16 idle state high
; movwf  SSPCON      ;mov w to spi control register

  bsf    SSPCON,5

If you study that code, and then also study the ASM code generated
by the CCS compiler for the setup_spi() library function, then you
can see that this line of C code does the same thing:
Code:
setup_spi(SPI_MASTER | SPI_L_TO_H | SPI_CLK_DIV_16);


That's probably the easy part. If I was writing the driver, I would look
at page 5 of the ADE7756 data sheet which shows the SPI read and
write timing diagrams. I would use CCS library functions to do the
same thing as shown in the diagrams.
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