This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Max6675 with TM4C123GH6PM Data Register Issues

TM4C123GH6PM with SPI Receive - Data Register remains 0


Apparently this exact question was asked but never answered 13 years ago as the asker never uploaded their code so I'll ask. All my settings
are correct but when it comes to receiving, it just doesn't occur, that is the
SSI1->DR remains empty even though everything is plugged in correctly with respect
to pinout and I'm operating at a relatively low clock speed at 10 kHz. Shown below
is the code, can anyone offer any suggestions?


#include "TM4C123.h" // Device header
#include <stdint.h>


void SSI1_INIT(void);
void SSI1_READ_TEMP();
void Timer0AMsDelay(int delay);


int main(){


SSI1_INIT();

Timer0AMsDelay(1000);
SSI1_READ_TEMP();


while(1){}

}

void SSI1_INIT(void){

SYSCTL->RCGCSSI |= 0x02; //Enable clock for SSI1
SYSCTL->RCGCGPIO |= 8; //Enable clock for GPIOD
SYSCTL->RCGCGPIO |= 0x20; //Enable clock for GPIOF

GPIOD->AMSEL &= ~0x05; /* disable analog for these pins */
GPIOD->DEN |= 0x05; //Digital enable GPIOD, pin 0 and pin 2
GPIOD->AFSEL |= 0x05; //Alternate function enable GPIOD, pin 0 and pin 2
GPIOD->PCTL &= ~0x00000F0F;
GPIOD->PCTL |= 0x00000202; //Enable SSI1 SCK for GPIOD, pin 0 and SSI1 RX for GPIOD, pin 2. p1351 0010 0000 0010

GPIOF->DEN |= 0x04; //Digitally enable GPIOF, pin 2
GPIOF->DIR |= 0x04; //GPIOF, pin 2 set as output
GPIOF->PUR |= 0x4; //GPIOF, pin 2 set as output
GPIOF->DATA |= 0x04; //


SSI1->CR1 = 0; //Clear enable bit to change parameters
SSI1->CC = 0; //
SSI1->CPSR |= 0x20; /* prescaler divided by 32*/
SSI1->CR0 |= 0x310F; /* Further clock div by 50 to get 10 kHz, SPI mode master,
16 bit data, CPOL = 0, CPHA = 1 --> 0b 0011 0001 0000 1111 */
SSI1->CR1 |= 0x2; /* enable SSI1 */

}


void SSI1_READ_TEMP(){
uint16_t data = 0;
GPIOF->DATA &= ~0x04;
while(!(SSI1->SR & 0x8)){} //p974 - wait here while Receive Not Empty is true
data = SSI1->DR; //Write data to data register
while(SSI1->SR & 0x10){} //p974 - wait here while SSI is busy
GPIOF->DATA |=0x04;
}


void Timer0AMsDelay(int delay){

SYSCTL->RCGCTIMER |= 1;
TIMER0->CTL = 0;
TIMER0->CFG = 0x04;
TIMER0->TAMR = 0x02;
TIMER0->TAILR = 16000 - 1;
TIMER0->ICR = 0x1;
TIMER0->CTL = 0x01;

for(int i = 0; i < delay; i++)
{
while((TIMER0->RIS & 0x1) == 0){}
TIMER0->ICR = 0x1;
}

}