Other Parts Discussed in Thread: TM4C123GH6PM, SW-TM4C
Hello ,
I am trying to initialize the SSI peripheral by writing my own drivers. I am using the EK-TM4C123GXL eval board. The port used is the SSI0. These are mapped onto pins - PA(5:2).
The code is as stated below -
- #include <tm4c123gh6pm.h>
- #include <stdint.h>
- #define LED_RED 0x02
- #define LED_BLUE 0x04
- #define LED_GREEN 0x08
- void main(void) {
- // initialise SPI bus //
- // PA(2:5) -
- // PA(2) - SSI0CLK
- // PA(3) - SSI0Fss
- // PA(4) - SSI0Rx
- // PA(5) - SSI0Tx
- int countTest = 0;
- // -- SPI initialisation -- //
- // SPI CLOCK FOR SSI0 //
- SYSCTL_RCGCSSI_R = 0;
- SYSCTL_RCGCSSI_R |= 1;
- // GPIO_A clock //
- SYSCTL_RCGCGPIO_R = 0;
- SYSCTL_RCGCGPIO_R |= 1;
- GPIO_PORTA_PCTL_R = 0;
- GPIO_PORTA_PCTL_R = 0x00222200;
- //GPIO_PORTA_AFSEL_R = 0;
- //GPIO_PORTA_AFSEL_R |= 0x3C;
- //GPIO_PORTA_DEN_R = 0;
- //GPIO_PORTA_DEN_R |= 0x3C;
- // SSI is disabled //
- // Maybe an if-else needed to check if enable is set //
- SSI0_CR1_R &= 0;
- // SSI configuration //
- SSI0_CR1_R |= 1; // - loop-back enabled //
- SSI0_CPSR_R = 0x00000002;
- SSI0_CR0_R = 0x000009C7;
- SSI0_CR1_R |= 2;
- //
- //
- // SSI0_CC_R = 0; // - sysclk for SSI - //
- // SSI0_CPSR_R = 0;
- // SSI0_CPSR_R |= 0x02; // - CLK prescale divisor - //
- //
- // SSI0_CR0_R = 0;
- // SSI0_CR0_R |= 0x0707; // - serial clock rate and 8 bit -- //
- //
- // SSI0_CR1_R |= 2; // - SSI peripheral started - //
- ///////////////////////
- // -- SPI initialisation done -- //
- while(1){
- SSI0_DR_R = 0x0008;
- //GPIO_PORTA_DATA_R |= 0x08;
- //GPIO_PORTA_DATA_R &= 0xF7;
- for(countTest = 0;countTest <= 62000;countTest++);
- for(countTest = 0;countTest <= 62000;countTest++);
- for(countTest = 0;countTest <= 62000;countTest++);
- //GPIO_PORTA_DATA_R |= 0x08;
- for(countTest = 0;countTest <= 62000;countTest++);
- for(countTest = 0;countTest <= 62000;countTest++);
- for(countTest = 0;countTest <= 62000;countTest++);
- }
There are no errors and it compiles. But there is no activity on any of the SPI lines. Now, the Fss pin is the SS(slave select). So after the SSI is enabled, should I actually toggle this Fss pin ? Is this action needed for the data to be latched onto the MOSI pin and then transmitted ?