|
|
View previous topic :: View next topic |
Author |
Message |
Guest
|
SPI confusing SPI_Xfer(). |
Posted: Thu Oct 15, 2009 3:24 am |
|
|
I use the hardware spi on the pic.
I have a module where one pin is to enable this module before the SPI communication start.
I expect the Enable=PIN_A3 to activate pin A3 before the SPI function invoked, but in the list file it not look like, expect SPI_Xfer().
Code: | #use spi(Master,SPI1,Force_HW,Enable=PIN_A3)
|
Will it say: SPI_Xfer() is using the setup from #use spi().
-And SPI_Read/SPI_Write just use the hardware reg.
The function SPI_Xfer is a much longer asm code compared to SPI_Read/SPI_Write, but the feature Enable= and other things only work on the function SPI_Xfer()?
|
|
|
Guest
|
|
Posted: Thu Oct 15, 2009 3:50 am |
|
|
This is from the startup code in main, think there is a bug:
Why is pin A3 = high when the SPI is not active?
Code: | #use spi(Master,SPI1,Force_HW,Enable=PIN_A3,ENABLE_ACTIVE=1) |
0224: BCF TRISA.3 -> output, ok
0226: BSF LATA.3 -> why not low?
I change ENABLE_ACTIVE=0 but no change in lst. file. |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Thu Oct 15, 2009 12:28 pm |
|
|
Quote: | Will it say: SPI_Xfer() is using the setup from #use spi().
-And SPI_Read/SPI_Write just use the hardware reg.
|
#use spi() uses spi_xfer(). setup_spi() uses spi_write() and spi_read().
Do not mix the two methods.
Quote: | The function SPI_Xfer is a much longer asm code compared to SPI_Read/SPI_Write, but the feature Enable= and other things only work on the function SPI_Xfer()? |
With setup_spi(), you must handle the Chip select for the slave with
your own code. Use output_low(CS_PIN) and output_high(CS_PIN).
Quote: | I change ENABLE_ACTIVE=0 but no change in lst. file. |
Post your PIC and your compiler version. |
|
|
Guest
|
|
Posted: Fri Oct 16, 2009 1:07 am |
|
|
Thanks for the explanation:-) |
|
|
|
|
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
|