|
|
View previous topic :: View next topic |
Author |
Message |
kazanova64
Joined: 10 Apr 2010 Posts: 8
|
|
Posted: Sat Aug 07, 2010 5:07 am |
|
|
Quote: | What's your compiler version ? |
i don't exactly know, old one i think. School computers
Although i changed it to below code, it doesn't change.
Code: | #use spi(FORCE_HW, MASTER, MODE=0, SAMPLE_RISE, BITS=8) |
I cannot init MAC on enc28j60 because there is an if statement that check a register's LSB is 1. But SPI can't read LSB.Do you think that below code is enough to setup the SPI for ENC, which SPI setup is given above?
Code: | setup_spi(SPI_MASTER | SPI_L_TO_H | SPI_XMIT_L_TO_H | SPI_CLK_DIV_4) |
|
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Sat Aug 07, 2010 11:15 am |
|
|
Quote: | I don't exactly know, old one i think. School computers
|
Look at the top of the .LST file. It gives the version, which will be in
this format: x.xxx The .LST file will be in your project directory after
a successful compilation. Also, sometimes there may be a letter suffix
on the end, such as x.xxxb if it's an limited version.
In older versions of the compiler, #use spi() was buggy. It defaulted to
incorrect parameters. For example, it defaulted to LSB_FIRST, which
is wrong for at least 95% of SPI devices. Also, early versions were
very picky about having the certain parameters present in the #use spi
statement. If you left some of them out, it wouldn't compile.
Quote: |
Do you think that below code is enough to setup the SPI for ENC, which SPI setup is given above?
Code:
setup_spi(SPI_MASTER | SPI_L_TO_H | SPI_XMIT_L_TO_H | SPI_CLK_DIV_4)
|
Based on the SPI mode definitions below, which you should use,
you are using SPI Mode 0.
Code: | // SPI mode definitions.
#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)
|
To find the SPI mode used by the ENC28J60, look in the data sheet,
http://ww1.microchip.com/downloads/en/DeviceDoc/39662c.pdf
in this section:
Quote: | 4.0 SERIAL PERIPHERAL INTERFACE (SPI)
|
It says:
Quote: |
The implementation used on this
device supports SPI mode 0,0 only.
|
So you are using the correct mode. |
|
|
kazanova64
Joined: 10 Apr 2010 Posts: 8
|
|
Posted: Sat Aug 07, 2010 5:07 pm |
|
|
CCS PCH C Compiler, Version 4.068
My version is quite old i think. I will renew it soon.
SAMPLE_RISE is a problem there because ENC sends data in idle to active statement, so i need to read it in active to idle. Change it and no problem in spi communication.
Thanks a lot and good works.
Omer |
|
|
|
|
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
|