Hi, can anyone help me? I'm trying to use de SSI interface of my microcontroler. Cause I have no clear how to program it I decided set the loopback flag. I selected the SSI2 as master. I send some data but all i have recieved is 0x0000.
I've tried with SSI3 too.
Any ideas?
I paste my code:
void SPI2_Init(void){ //Puerto b4,b5,b6,b7 -> clk, Fss,rx,tx
SYSCTL_RCGCSSI_R|=0x04; //enable module ssi2
SYSCTL_RCGCGPIO_R |=0x02; //clock puerto B
GPIO_PORTB_AFSEL_R |= 0xF0; //alternate function select en pines
GPIO_PORTB_PCTL_R |=0x22220000; //bits 7,6,5,4 funcion sspi2 tabla 23-5
GPIO_PORTB_DEN_R |= 0xF0; //son digitales
//GPIO_PORTB_PUR_R |=0x80; //pullup en clock para steady state high
SSI2_CR1_R &= ~0x02; //inhabilita SSI2 bit SSE
SSI2_CR1_R |= 0x01; //loopback
SSI2_CR1_R &= ~0x04; //master
SSI2_CC_R &= ~0x07; //clock ssi igual al del sistema y factor de division
SSI2_CPSR_R |= 0x32; //50d //BR=SysClk/(CPSDVSR * (1 + SCR) (bit rate=clock/valor pongo en cpsr *(i sr que pongo en cro)
SSI2_CR0_R |=0x5827; //SCR=1 MICROWIRE
SSI2_IM_R |=0x04; //habilita interrupcion en rx
SSI2_CR1_R |= 0x02; //habilita SSI2 bit SSE
}
void SPI2_envia(unsigned char letra){
unsigned short palabra16=0x2222;
unsigned char bitbusy;
bitbusy=SSI2_SR_R & 0x40;
palabra16 |= letra;
while(bitbusy==0x40){}; //wait while busy
SSI2_DR_R =palabra16; //write to send.
}
void SSI2_Handler(void){
unsigned long data;
while((SSI2_SR_R & 0x04)==0x04 ){ //fifo rx no empty
if((SSI2_SR_R & 0x10) ==0x00){ //no busy
data= SSI2_DR_R ;
}
}
}