Hi,
Every time I have to look at the SPI settings, I get the problem of the different ways of understanding: CPOL CPHA CKE CKP SMP. It simply knots my brain, even though I can read it ok.
Here is my SPI set-up all commented for me to scan through, but it doesn't have CPHA or CPOL anywhere.
Can someone inject CPOL and CPHA in to it as simple as possible please? No explanations needed, just the minimum to make it clear.
Cheers, C.
'*******************************************************
'* *
'* START UP SPI ROUTINE *
'* *
'*******************************************************
Proc init_spi() 'PIC 18F46K20
TRISC.3 = 0 'SCK to Slave ****** output *******
TRISC.5 = 0 'MOSI ****** output *******
TRISC.4 = 1 'MISO ****** input *******
'MODE ????
SSPSTAT.SMP = 0 '1 = Input data sampled at end of data output time
'0 = Input data sampled at middle of data Output time
SSPSTAT.CKE = 0 '1 = Output data changes on clock transition from active to idle
'0 = Output data changes On clock transition from idle To active
SSPSTAT.5 = 0 'I2C only
SSPSTAT.4 = 0 'I2C only
SSPSTAT.3 = 0 'I2C only
SSPSTAT.2 = 0 'I2C only
SSPSTAT.1 = 0 'I2C only
SSPCON1 = 0 'RESET THE CONTROL REGISTER **ADDED
SSPCON1.WCOL = 0 'Collision detect
SSPCON1.SSPOV = 0 'Overflow
SSPCON1.SSPEN = 1 'Configure SCK,SD0,SDI,/SS ** HAS TO BE 1. To reset or reconfigure SPI mode, clear the SSPEN bit,
'reinitialize the sspcon registers And Then set the SSPEN Bit from the datasheet !!
SSPCON1.CKP = 1 '1 = Idle state for clock is a high level
'0 = Idle state For clock is A Low level
SSPCON1.SSPM3 = 0 '0000 = SPI Master mode, clock = FOSC/4
SSPCON1.SSPM2 = 0
SSPCON1.SSPM1 = 0 ''SPI Master mode, clock = F OSC/4
SSPCON1.SSPM0 = 0
End Proc
*************************************************************************************
Every time I have to look at the SPI settings, I get the problem of the different ways of understanding: CPOL CPHA CKE CKP SMP. It simply knots my brain, even though I can read it ok.
Here is my SPI set-up all commented for me to scan through, but it doesn't have CPHA or CPOL anywhere.
Can someone inject CPOL and CPHA in to it as simple as possible please? No explanations needed, just the minimum to make it clear.
Cheers, C.
'*******************************************************
'* *
'* START UP SPI ROUTINE *
'* *
'*******************************************************
Proc init_spi() 'PIC 18F46K20
TRISC.3 = 0 'SCK to Slave ****** output *******
TRISC.5 = 0 'MOSI ****** output *******
TRISC.4 = 1 'MISO ****** input *******
'MODE ????
SSPSTAT.SMP = 0 '1 = Input data sampled at end of data output time
'0 = Input data sampled at middle of data Output time
SSPSTAT.CKE = 0 '1 = Output data changes on clock transition from active to idle
'0 = Output data changes On clock transition from idle To active
SSPSTAT.5 = 0 'I2C only
SSPSTAT.4 = 0 'I2C only
SSPSTAT.3 = 0 'I2C only
SSPSTAT.2 = 0 'I2C only
SSPSTAT.1 = 0 'I2C only
SSPCON1 = 0 'RESET THE CONTROL REGISTER **ADDED
SSPCON1.WCOL = 0 'Collision detect
SSPCON1.SSPOV = 0 'Overflow
SSPCON1.SSPEN = 1 'Configure SCK,SD0,SDI,/SS ** HAS TO BE 1. To reset or reconfigure SPI mode, clear the SSPEN bit,
'reinitialize the sspcon registers And Then set the SSPEN Bit from the datasheet !!
SSPCON1.CKP = 1 '1 = Idle state for clock is a high level
'0 = Idle state For clock is A Low level
SSPCON1.SSPM3 = 0 '0000 = SPI Master mode, clock = FOSC/4
SSPCON1.SSPM2 = 0
SSPCON1.SSPM1 = 0 ''SPI Master mode, clock = F OSC/4
SSPCON1.SSPM0 = 0
End Proc
*************************************************************************************











