Can't write to SPI data register. MC9S08JM60

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Can't write to SPI data register. MC9S08JM60

Jump to solution
872 Views
Coderunner
Contributor III

Hello,

 

I am trying to utilize SPI2 module as SPI Master to read data from a slave device.

 

I have successfully setup SPI1 module as master/bidirectional to send data to another device (without the need to get anything in return).

 

I ran the code in debugger to test it without the slave device yet. The problem is that it won't write data to the SPI2 data registers no matter what I do.

 

Please look at my code and tell me what am I doing wrong.

 

void main(void){  ...  //Initialize SPI2 Module  SPI2C1_SPE = 0;                   //disable SPI2 Module  SPI2C1 = 0b00010011;          //disable SPI Ints, SPI Master Mode 0, SS enabled, data LSB first  SPI2C2 = 0b00010000;          //8-bit mode, data uses MISO & MOSI pins  SPI2BR = 0b00010010;          //set baud rate     SPI2C1_SPE = 1;                   //enable SPI2 Module  temp = Getdata(0xFF);  ...}//*** FUNCTION - Get Databyte Getdata(byte data){  while(SPI2S_SPTEF!=1);        //wait until transmit buffer is empty   SPI2DL = data;                    //send dummy **** THIS DOES NOT WORK **** SPI2DL ALWAYS = 0x00  while(SPI1S_SPRF!=1);         //wait until data is ready in receive data buffer  data = SPI2DL;  return data;  } 

 

Thank you

Labels (1)
0 Kudos
1 Solution
451 Views
Coderunner
Contributor III

OK, solved the problem.

 

I am using DEMOJM devolpment board which has multiple deviced on it interfaced with the micro for testing.

The SPI2 I/Os were being hugged by some of these deviced.

I removed the jumpers, thus freeing the lines and now it WORKS!!! DUH!!!

View solution in original post

0 Kudos
2 Replies
451 Views
Coderunner
Contributor III

I want to add an interesting finding.

 

As I've mentioned before, I have SPI1 module working. I use it to send data to a LED driver.

 

I replaced the SPI1 with SPI2. Everything is exactly the same but using SPI2 instead of SPI1. SPI1 DISABLED.

 

DOES NOT WORK!!!!???

 

 

0 Kudos
452 Views
Coderunner
Contributor III

OK, solved the problem.

 

I am using DEMOJM devolpment board which has multiple deviced on it interfaced with the micro for testing.

The SPI2 I/Os were being hugged by some of these deviced.

I removed the jumpers, thus freeing the lines and now it WORKS!!! DUH!!!

0 Kudos