please dont rip this site

PIC Micro Controller C Input / Output Routine


SPI Setup

by Peter Schutz

void init_spi_communication ( void )
 {
  TRISC4 = 1;   //SPI Slave In
  TRISC5 = 0;   //SPI Slave Out
  TRISC3 = 1;   //SPI Slave CLK In
  TRISA5 = 1;   //SPI SS Enabled In, used for other purpose then SPI
     SMP = 0;   //SPI slave mode
   SSPEN = 1;   //SPI port pins enabled
   SSPM0 = 0;   //Slave Mode SS pin Disabled
   SSPM1 = 0;
   SSPM2 = 1;
   SSPM3 = 0;
     CKP = 1;   //Clock idle is high
     CKE = 0;   //Data on rising edge
 }

void main ( void )
 {
  hardware_init();
  initialize ();
  init_spi_communication ();    // Initialization of SPI
  SSPBUF = 0x00;                        // Clear SPI receive buffer
  SSPIE = 1;                      // Enable interrupt on SPI receiving
  PEIE = 1;                             // Enable peripherial interrupt(For
SPI)
  ei();                         // Global interrupt enable
  asm("sleep");                 // Going to sleep
  while (1)
   ;
 }

Questions:

Comments:


file: /techref/microchip/language/c/spiinit.htm, 2KB, , updated: 2007/11/9 10:41, local time: 2008/11/22 02:30,
TOP NEW HELP FIND: 
38.103.63.58:LOG IN
©2008 PLEASE DON'T RIP! DO: LINK / DIGG! / MAKE!

 ©2008 These pages are served without commercial sponsorship. (No popup ads, etc...).Bandwidth abuse increases hosting cost forcing sponsorship or shutdown. This server aggressively defends against automated copying for any reason including offline viewing, duplication, etc... Please respect this requirement and DO NOT RIP THIS SITE. Questions?
Please DO link to this page! Digg it!
<A HREF="http://www.piclist.com/techref/microchip/language/c/spiinit.htm"> PIC Micro Controller C Input / Output Routine</A>

After you find an appropriate page, you are invited to your to this massmind site! (posts will be reviewed) Just type in the box and press the Post button. (HTML welcomed!): A tutorial is available Members can login to post directly, become page editors, and be credited for their posts.


Link? Put it here: 
if you want a response, please enter your email address: 
Did you find what you needed?

  PICList 2008 contributors:
o List host: MIT, Site host massmind.org, Top posters @20081122 Apptech, Jinx, Xiaofan Chen, olin piclist, Vitaliy, William \Chops\ Westfield, Tamas Rudnai, JonnyMac, Alan B. Pearce, Gerhard Fiedler,
* Page Editors: James Newton, David Cary, and YOU!
* Roman Black of Black Robotics donates from sales of Linistep stepper controller kits.
* Ashley Roll of Digital Nemesis donates from sales of RCL-1 RS232 to TTL converters.
* Monthly Subscribers: Shultz Electronics, Timothy Weber, on-going support is MOST appreciated!
* Contributors: Richard Seriani, Sr.
  'What can I do?' - SiCKO

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

  .