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

PIC24F16KA102 SPI

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



Joined: 29 Feb 2012
Posts: 1

View user's profile Send private message

PIC24F16KA102 SPI
PostPosted: Wed Feb 29, 2012 6:33 am     Reply with quote

I'm new to PIC's and I am probably missing something very simple, but I can't get the h/w SPI to work.

The serial clock pin is pulled high and the data pin stays low.

My code is as follows, I've loaded it into two24F16KA102's, and I am using a scope to view the IC pins.

Code:


#include <24F16KA102.h>
// compiler v4.120

#device ICD=TRUE

#fuses MCLR,NOWDT,NOPROTECT,NOBROWNOUT,HS

#use delay (clock=4M)

void main() {

/* while (true) {
   output_toggle (PIN_B10); // check port h/w works- OK squarewaves can be seen
   output_toggle (PIN_B11); // tried another chip too!
   delay_ms(20);
   } */

// setup_spi(SPI_MASTER | SPI_H_TO_L | SPI_XMIT_L_TO_H | SPI_CLK_DIV_16);
setup_spi(SPI_MASTER | SPI_H_TO_L | SPI_CLK_DIV_16);

while (true)


 {
   spi_write (0xFF);       // RB10 sclk is pulled high
   delay_ms(500);          // RB11 sdata is 0V
   spi_write (0x00);
   delay_ms(500);
   
   output_toggle(PIN_A4); //heartbeat LED OK!
 }
   
}


Any suggestions and help for a newbie will be gladly received.
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