|
|
View previous topic :: View next topic |
Author |
Message |
saran3 Guest
|
how to access internal spi registers |
Posted: Thu Oct 11, 2007 6:08 am |
|
|
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
|
|
Posted: Thu Oct 11, 2007 7:50 am |
|
|
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 |
|
|
|
|
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
|