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 problem (not even clock) with PIC18F452

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



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sat Feb 19, 2011 1:25 pm     Reply with quote

Run a simple test program. Then look at Pin C3 for the SPI clock.
Example:
Code:

#include <18F452.h>
#fuses HS, NOWDT, PUT, BROWNOUT, NOLVP   
#use delay(clock = 20000000)   

#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)

//========================================
void main()
{

setup_spi(SPI_MASTER | SPI_MODE_0 | SPI_CLK_DIV_64);

while(1)
  {
   spi_write(0x55);
   delay_us(100);
  }

}

Don't run it in Debug mode. Don't attempt to step through the code.
Compile and run it in Release mode. You should see the SPI clock.
Nora



Joined: 23 Mar 2008
Posts: 50

View user's profile Send private message

PostPosted: Sat Feb 19, 2011 1:33 pm     Reply with quote

I DO see the clock.
Thanks!
Ttelmah



Joined: 11 Mar 2010
Posts: 19369

View user's profile Send private message

PostPosted: Sat Feb 19, 2011 4:17 pm     Reply with quote

And, on sending 16bits, just send two lots of 8bits. The _hardware_ only sends 8bits at a time, and if you load a new byte immediately, the transaction is effectively 'non stop' (which shouldn't matter anyway with SPI - this is why it sends a clock...).

Best Wishes
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