View previous topic :: View next topic |
Author |
Message |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Sat Feb 19, 2011 1:25 pm |
|
|
Run a simple test program. Then look at Pin C3 for the SPI clock.
Example:
Code: |
#include <18F452.h>
#fuses HS, NOWDT, PUT, BROWNOUT, NOLVP
#use delay(clock = 20000000)
#define SPI_MODE_0 (SPI_L_TO_H | SPI_XMIT_L_TO_H)
#define SPI_MODE_1 (SPI_L_TO_H)
#define SPI_MODE_2 (SPI_H_TO_L)
#define SPI_MODE_3 (SPI_H_TO_L | SPI_XMIT_L_TO_H)
//========================================
void main()
{
setup_spi(SPI_MASTER | SPI_MODE_0 | SPI_CLK_DIV_64);
while(1)
{
spi_write(0x55);
delay_us(100);
}
} |
Don't run it in Debug mode. Don't attempt to step through the code.
Compile and run it in Release mode. You should see the SPI clock. |
|
![](templates/subSilver/images/spacer.gif) |
Nora
Joined: 23 Mar 2008 Posts: 50
|
|
Posted: Sat Feb 19, 2011 1:33 pm |
|
|
I DO see the clock.
Thanks! |
|
![](templates/subSilver/images/spacer.gif) |
Ttelmah
Joined: 11 Mar 2010 Posts: 19369
|
|
Posted: Sat Feb 19, 2011 4:17 pm |
|
|
And, on sending 16bits, just send two lots of 8bits. The _hardware_ only sends 8bits at a time, and if you load a new byte immediately, the transaction is effectively 'non stop' (which shouldn't matter anyway with SPI - this is why it sends a clock...).
Best Wishes |
|
![](templates/subSilver/images/spacer.gif) |
|