CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

SPI confusing SPI_Xfer().

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Guest








SPI confusing SPI_Xfer().
PostPosted: Thu Oct 15, 2009 3:24 am     Reply with quote

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








PostPosted: Thu Oct 15, 2009 3:50 am     Reply with quote

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

View user's profile Send private message

PostPosted: Thu Oct 15, 2009 12:28 pm     Reply with quote

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








PostPosted: Fri Oct 16, 2009 1:07 am     Reply with quote

Thanks for the explanation:-)
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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