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 CCS Technical Support

18F4620 SPI communication

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







18F4620 SPI communication
PostPosted: Wed Sep 20, 2006 5:06 am     Reply with quote

Here is my sample code:
//---------------------------------------------
setup_spi(SPI_SLAVE|SPI_L_TO_H|SPI_CLK_DIV_4);

while(1)
{
while( !spi_data_is_in() )
{ }
Var1 = spi_read();
printf("Received : %d\n\r", Var1);
}
//----------------------------------------------
And Iam sending SPI data from another microcontroller.
Data is 0,1,2,3,..100 with 500ms intervals. Iam using
PIC18F4620 and CCS C V4.010. But I read
0,3,4,7,8,11,12,15,16,19,20,23,24,27,28,31... values
in 18F4620. You see that there is a characteristic
error (Always same values are disappearing). When I
use PIC18F452 there is no problem and I can see
0,1,2,3,4,5,6,7,8,9,... rigth values. What is problem
whit 18F4620.
ckielstra



Joined: 18 Mar 2004
Posts: 3680
Location: The Netherlands

View user's profile Send private message

PostPosted: Wed Sep 20, 2006 7:02 am     Reply with quote

Code:
setup_spi(SPI_SLAVE|SPI_L_TO_H|SPI_CLK_DIV_4);
A SPI slave is using the clock signal as supplied by the SPI master. Remove the SPI_CLK_DIV_4 from your code as it will cause an incorrect configuration to be written to the SPI registers with undefined behaviour as result.
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