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

how to access internal spi registers

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







how to access internal spi registers
PostPosted: Thu Oct 11, 2007 6:08 am     Reply with quote

Is it possible to access internal spi registers and write the code in the same manner as in ASM instead of using spi functions , because i am unable to communicate with the spi device with the help of SPI functions
Guest








PostPosted: Thu Oct 11, 2007 7:50 am     Reply with quote

Totally.
Use the CCS #byte directive.
So (fora PIC 18):
Code:

//Byte definitions for the SSP registers
#byte   SSPBUF = 0xFC9
#byte   SSPCON = 0xFC6
#byte   SSPSTAT = 0xFC7

//bit definitions for the enable, and buffer full
#bit  SSPEN = 0xSSPCON.5
#bit BF = SSPSTAT.0

#DEFINE READ_SSP()   (SSPBUF)
#DEFINE   WAIT_FOR_SSP()   while(!BF)
#DEFINE   WRITE_SSP(x)   SSPBUF=(x)
#DEFINE   CLEAR_WCOL()   SSPCON=SSPCON & 0x3F


So, then an instruction like:

WRITE_SSP(0x10);

Will just write '0x10', into the SSPBUF register.

Then, after this:
Code:

WAIT_FOR_SSP() {
    //do what you want here, while waiting for the SSP buffer full bit to set
}
val=READ_SSP();

Will wait for the current SSP transfer (triggered by the write), to complete, and then read the byte.

It is actually much more efficient to do things tis way, since you can perform other jobs, while waiting for the current byte to transfer, which the CCS implementation, does not allow.

Best Wishes
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