Hi, I have written some code in order to activate an SPI interface on my TM4C123GH6PM micro.
#include "tm4c123gh6pm.h" #include <stdint.h> void ssi_init(void){ volatile unsigned long delay; SYSCTL_RCGC1_R |= SYSCTL_RCGC1_SSI0; //activate SSI0 SYSCTL_RCGC2_R |= SYSCTL_RCGC2_GPIOA; //activate clock to PORTA delay = SYSCTL_RCGC2_R; GPIO_PORTA_AFSEL_R |= 0x2C; //activate alternate function on PA2,3,5 GPIO_PORTA_PCTL_R = (GPIO_PORTA_PCTL_R&0xFF0F00FF)+0x00202200; //pin control given to SSI0Fss, SSI0Clk and SSI0Tx GPIO_PORTA_DEN_R |= 0x2C; //enable digital on each pin SSI0_CR1_R &= ~SSI_CR1_SSE; //disable SSI during config SSI0_CR1_R &= ~SSI_CR1_MS; //master mode SSI0_CPSR_R = (SSI0_CPSR_R&~SSI_CPSR_CPSDVSR_M)+2; //8MHZ SSI0_CR0_R &= ~(SSI_CR0_SCR_M | SSI_CR0_SPH | SSI_CR0_SPO); //Freescale SPH=SPO=0 SSI0_CR0_R = (SSI0_CR0_R&~SSI_CR0_FRF_M)+SSI_CR0_FRF_MOTO; SSI0_CR0_R = (SSI0_CR0_R&~SSI_CR0_DSS_M)+SSI_CR0_DSS_8; //Frame length is 8-bit SSI0_CR1_R |= SSI_CR1_SSE; //enable SSI } void data_send(unsigned char data){ while((SSI0_SR_R&0x00000002)==0){}; //Wait for buffer SSI0_DR_R = data; //send data } int main(void){ unsigned char data = 0xAA; ssi_init(); while(1){ data_send(data); } }
The file contains an initialisation routine which was created using the databook and examples from Jonathan Valvano's book as a general guide. There is a second routine which places the test data into the SSI_DR register. To test it I i initialised a test frame and then just repeatedly call the data send routine.
Now my thoughts are that I should be able to see the pin change on SSIClk, SSITx and SSIFss using an oscilloscope but clearly I am doing something wrong because I can't see anything. Is it the code or my method of testing the interface or both. All help is greatly appreciated.