Tool/software: Code Composer Studio
Hello, I hope you all are doing great. I am trying to interface a QVGA TFT display with my board. I am using DRM along with some APIs. I have configured SSI0 module through the same steps mentioned in the datasheet, with ports A2, A3, A4, A5.
The connections are as below.
A2 (SCLK) going in the clock pin of LCD
A3 (FSS) going in CS (chip select or slave) of the LCD
A4(RX) going in MISO of LCD
A5(TX) going in the MOSI of LCD
(on the LCD board)DC pin data or command selection I don't know what this does, I am confused about this pin. I remember in the class I was told data is sent by the master to slave on a MOSI line then why this data pin? however, I have included it in the code as an output pin.
(on the LCD board) Reset active low
I also referred to an old post on the same topic tried to implement it but so far I am unsuccessful.
There is nothing on display, however, I am trying to display a text. Your help will be greatly appreciated. Thanks
#include <stdint.h> #include <stdbool.h> #include "driverlib/sysctl.h" #include "tm4c123gh6pm.h" #include "driverlib/gpio.h" #include "inc/hw_memmap.h" // PA 2,3,4,5 void spi_ini(void){ SYSCTL_RCGCSSI_R = 0x01; //selecting SSI0 module
SYSCTL_RCGC2_R = 0x01; // activating clock for port A
GPIO_PORTA_AFSEL_R = 0x3C; //selecting PA 2,3,4,5 for alternate functionality
GPIO_PORTA_PCTL_R = 0x00222200; // configuring the SSI with relative ports
GPIO_PORTA_DEN_R = 0x3C; //enabling digital mode
GPIO_PORTA_PUR_R= 0x3C; //pullups
SSI0_CR1_R= 0x00; // disabling ssi
SSI0_CC_R=0x00; // using main clock
SSI0_CPSR_R=64; // selecting divisor for clock
SSI0_CR0_R=0x07; // 8 bit data transfer
SSI0_CR1_R=0x02; // enabling SSI SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOE); // PE4 = D/C' , PE5 = RESET
GPIOPinTypeGPIOOutput(GPIO_PORTE_BASE, GPIO_PIN_4|GPIO_PIN_5);
GPIOPinWrite(GPIO_PORTE_BASE, GPIO_PIN_5,0x20);
SysCtlDelay(SysCtlClockGet()/2);// delay
GPIOPinWrite(GPIO_PORTE_BASE, GPIO_PIN_5,0);
SysCtlDelay(SysCtlClockGet()/2); } void send_byte(char data){ SSI0_DR_R=data; while(SSI0_SR_R&0x01==0){}; } void send_str(char*buffer){ while(*buffer!=0){ send_byte(*buffer); buffer++; } } int main(void) { SysCtlClockSet(SYSCTL_SYSDIV_5|SYSCTL_USE_PLL|SYSCTL_XTAL_16MHZ|SYSCTL_OSC_MAIN); spi_ini(); send_str("hello SPI"); }