|
|
View previous topic :: View next topic |
Author |
Message |
Geps
Joined: 05 Jul 2010 Posts: 129
|
Software SPI |
Posted: Wed Jul 06, 2011 6:46 am |
|
|
Hi,
I'm trying to communcate with an 96C56 EEPROM using my own driver (rather than CCS' provided one) and need to use the software implementation of SPI.
I've written a short test program and the software seems to be crashing on the spi_write() instruction. Using a logic anaylser the output_high(SPISS) line gets exectued but nothing there after. I'm able to toggle the pins so I know it's not a hardware issue.
Is there something regarding the software versions I should be aware of/am doing wrong?
CCS PCH C Compiler, Version 4.116
Test program:
Code: |
#include <18f4520.h>
#fuses INTRC_IO, NOMCLR, NOWDT, NOLVP, NOPUT
#use delay(internal = 8Mhz, clock=32MHz)
#use rs232(baud=115200, xmit=PIN_C6, rcv=PIN_C7, ERRORS)
#define SPI_SS PIN_B4
#use spi(DI=PIN_B2, DO=PIN_B1, CLK=PIN_B3)
void main() {
delay_ms(1000);
while(TRUE){
// select slave - this device has high chip select
output_high(SPI_SS);
spi_write(10);
delay_ms(1000);
}
}
|
|
|
|
SH
Joined: 06 Jul 2011 Posts: 3
|
|
Posted: Wed Jul 06, 2011 7:16 am |
|
|
There is an example for the 93C56:
C:\Program Files (x86)\PICC\drivers\9356spi
Maybe it will help you. |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Wed Jul 06, 2011 2:15 pm |
|
|
Quote: | #use spi(DI=PIN_B2, DO=PIN_B1, CLK=PIN_B3)
spi_write(10); |
The spi_write() function only uses the hardware SPI pins. You must use
the spi_xfer() function with #use spi() for software SPI. spi_xfer() is
intended to be used with #use spi().
The spi_write() and spi_read() functions are for the older setup_spi() method.
Also, depending upon your compiler version, the #use spi() library may
not default to parameters that you expect. It likely defaults to the exact
opposite of what you want. That's what I've found in older compiler
versions. You need to add the following parameters to your #use spi()
declaration:
Code: |
MASTER, MSB_FIRST, BITS=8, MODE=0, BAUD=100000
|
If your SPI mode is different, or if your Baudrate is different, you can
change them to what you need. |
|
|
Geps
Joined: 05 Jul 2010 Posts: 129
|
|
Posted: Thu Jul 07, 2011 9:20 am |
|
|
SH, for my application I have to use the software port so the CCS provided driver isn't any use unfortunately.
Thanks PCM - thought it might be something simple! |
|
|
|
|
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
|