Richard Pattinson

S12xDP512 SPI problem

Discussion created by Richard Pattinson on Dec 1, 2006
Latest reply on Dec 1, 2006 by Richard Pattinson
Hi,
 
I am trying to communicate with a MAX7219 over spi from the above CPU with a 16bit transfer.
 
The 7219 nees the /SS pin to go high after the 16th bit to latch the data, for this reason i cannot use the /SS pin under cpu control.
 
I am now trying to manually set the /SS port pin with the following code. The /SS is set to an output.
 
 //SPI Setup - Done at startup
 SPI0CR1 = 0x50;
 SPI0CR2 = 0x00;
 SPI0BR = 0x05;
 
// Spi TX function
 U8 i = 0
 
// Select the 7129
 DioROT6.Bits.LED_CS = 0;   
 
 // Send Data
  for(i = 0; i < 2;i ++)
  {
    SPI0DR = 0x0B;
    while(!(SPI0SR & 0x20));
  }  
  
// Deslect the 7219
 DioROT6.Bits.LED_CS = 1; 
 
But for some reason the /SS port pin is going hi (deselecting) after the first byte has been sent. It would appear that the second test if the tx buffer is empty is not working.
 
Can anyone see why this would be the case or what i could be doing wrong?
 
Regards
R

Outcomes