View previous topic :: View next topic |
Author |
Message |
mjdale2003
Joined: 10 Oct 2004 Posts: 21 Location: UK
|
SPI 18f4455 |
Posted: Wed Jun 29, 2005 2:49 am |
|
|
Hello can anyone help with the problem im having :
Iwish to use the spi port as a shift regester to send 8bits of data in 8 clock cycles from D0 so that i dont have to waste the cycles shifting the data myself any ideas anyone? |
|
|
Ttelmah Guest
|
|
Posted: Wed Jun 29, 2005 3:12 am |
|
|
It might help if you said what the 'problem' is!.
The SPI port, _is_ a shift register. If you setup the SPI, with something like:
setup_spi(SPI_MASTER|SPI_L_TO_H|SPI_CLK_DIV_4);
Then use SPI_WRITE(0x55);
You will get the byte output on the SDO pin, with the clock used on the SCL pin.
The fastest clock available, is the oscillator/4 (same as a single instruction time). Data is sent MSB first, and you can change to 'SPI_H_TO_L' to clock it on the other edge if required.
Best Wishes |
|
|
mjdale2003
Joined: 10 Oct 2004 Posts: 21 Location: UK
|
|
Posted: Thu Jul 07, 2005 9:21 am |
|
|
Hi, thanks for the input but it seems that i still cant get it to work, the aplication is not actualy conected to anything i just wish to use the spi as a shift regester so i dont have to do it in software and to save instructions |
|
|
Ttelmah Guest
|
|
Posted: Thu Jul 07, 2005 2:22 pm |
|
|
So describe your problem.
The most likely things to stop it working, are an incorrectly set TRIS register (if you are controlling this yourself), an old compiler version (there were some problems here a while ago), or some other peripheral interfering with the setup (remember the hardware I2C uses the same pins).
It will just shift the data out.
Best Wishes |
|
|
|