AnsweredAssumed Answered

One Way SPI Communications

Question asked by Sergey Pilipchuk on May 19, 2010
Latest reply on May 27, 2010 by Sergey Pilipchuk

Hello everyone,

 

I've been fighting all day trying to get SPI to work to no avail. I am trying to use SPI1 Module on MC9S08JM60 to send data to a driver (pretty much acts like a serial to parallel out shift register). So I want to use SPI to send data and use its clock. Shouldn't I be able to send data to a non-spi device? Can't SPI be configure one-way, to just send out data and not care about any acknowlegement? Any ways here is the my code involving SPI:

 

 

void SPIsend(unsigned char data);unsigned char mydata=11;        //test data//*** MAIN *********************************************************void main(void) {   //*** Initialize SPI  SOPT2_SPI1FE = 0;             //disable input filter on SPI1 to allow higher SPI baud rate  SPI1C1 = 0x00;                //disable SPI1 Module  SPI1C2 = 0x49;                //16-bit mode, MOSI=Master I/O  SPI1BR = 0x00;                //set baud rate; prescaler divisor = 1, baud rate divisor = 2  SPI1S |= (unsigned char)0x40; //read-modify-write operation of the SPI1S registr to clear the MODF and SPIMF flags  SPI1M = 0x00;                 //clear data buffer  SPI1C1 = 0x54;                //enable SPI1,disable SPI Ints, clock active high, data MSB first    //*** FOREVER LOOP  for(;;)   {    __RESET_WATCHDOG();         //feeds the dog        SPIsend(mydata);  } }//*** END MAIN//*** SEND DATA USING SPI FUNCTIONvoid SPIsend(unsigned char data){  while(!SPI1S_SPTEF);          //wait until transmit buffer is empty  SPI1D=data;                   //write to Tx data buffer; start to send data  SPI1S;                        //read status register  return;}

 I get nothing on the SPI output (MOSI pin). Am I not initializing something right? I don't have to use SS right? Any help would be appreciated.

Outcomes