I have a library for 5110 lcd but it is written by using registers, and sometimes it blocks some of other peripherals. Now I want to drive 5110 lcd by using driverlib and I found library in forum. But the thing is on my custom pcb lcd is connected to ssi0 base and PA4 is used for backlight. I see that PA4 is rx pin of SSI and it is not needed to drive lcd. Without a modification library works properly, but when I add lines below, it goes fault_isr.
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
GPIOPinTypeGPIOOutput(GPIO_PORTA_BASE, GPIO_PIN_4); // goes Fault_isr at exactly that line
I tried to place these 2 lines to different locations but result is either it goes fault_isr or it has no effect.
By the way, I use the line below in main.c after lcd_init called,
GPIOPinWrite(GPIO_PORTA_BASE, GPIO_PIN_4, 16);
The rest of the init code:
void all_tasks_manager(void)
{
uint32_t ready_count;
/* cs high initially */
SysCtlGPIOAHBEnable(CE_PERIPH);
SysCtlPeripheralEnable(CE_PERIPH);
ready_count = 2000U;
while( (!(SysCtlPeripheralReady(CE_PERIPH))) && (--ready_count));
if(0U == ready_count) /* if periph not ready take action */
{
}
GPIOPinTypeGPIOOutput(CE_BASE, CE_PIN);
CE_HIGH();
/* reset low initially */
SysCtlGPIOAHBEnable(RESET_PERIPH);
SysCtlPeripheralEnable(RESET_PERIPH);
ready_count = 2000U;
while( (!(SysCtlPeripheralReady(RESET_PERIPH))) && (--ready_count));
if(0U == ready_count) /* if periph not ready take action */
{
}
GPIOPinTypeGPIOOutput(RESET_BASE, RESET_PIN);
RESET_LOW();
/* dc low initially */
SysCtlGPIOAHBEnable(DC_PERIPH);
SysCtlPeripheralEnable(DC_PERIPH);
ready_count = 2000U;
while( (!(SysCtlPeripheralReady(DC_PERIPH))) && (--ready_count));
if(0U == ready_count) /* if periph not ready take action */
{
}
GPIOPinTypeGPIOOutput(DC_BASE, DC_PIN);
DC_LOW();
/* enable SSI0 module */
SysCtlPeripheralDisable(SYSCTL_PERIPH_SSI0);
SysCtlPeripheralReset(SYSCTL_PERIPH_SSI0);
SysCtlPeripheralEnable(SYSCTL_PERIPH_SSI0);
while( (!(SysCtlPeripheralReady(SYSCTL_PERIPH_SSI0))) && (--ready_count));
if(0U == ready_count) /* if periph not ready take action */
{
}
/* enable clk */
SysCtlGPIOAHBEnable(SYSCTL_PERIPH_GPIOA);
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
while( (!(SysCtlPeripheralReady(SYSCTL_PERIPH_GPIOA))) && (--ready_count));
if(0U == ready_count) /* if periph not ready take action */
{
}
GPIOPinConfigure(GPIO_PA2_SSI0CLK);
GPIOPinTypeSSI(GPIO_PORTA_AHB_BASE , GPIO_PIN_2);
/* enable rx */
// SysCtlGPIOAHBEnable(SYSCTL_PERIPH_GPIOA);
// SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
// while( (!(SysCtlPeripheralReady(SYSCTL_PERIPH_GPIOA))) && (--ready_count));
// if(0U == ready_count) /* if periph not ready take action */
// {
// }
// GPIOPinConfigure(GPIO_PA4_SSI0RX);
// GPIOPinTypeSSI(GPIO_PORTA_AHB_BASE , GPIO_PIN_4);
/* enable tx */
SysCtlGPIOAHBEnable(SYSCTL_PERIPH_GPIOA);
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
while( (!(SysCtlPeripheralReady(SYSCTL_PERIPH_GPIOA))) && (--ready_count));
if(0U == ready_count) /* if periph not ready take action */
{
}
GPIOPinConfigure(GPIO_PA5_SSI0TX);
GPIOPinTypeSSI(GPIO_PORTA_AHB_BASE , GPIO_PIN_5);
/* disable SPi first */
SSIDisable(SSI0_BASE);
SSIDMADisable(SSI0_BASE , SSI_DMA_RX | SSI_DMA_TX);
SSIIntDisable(SSI0_BASE , SSI_TXFF | SSI_RXFF | SSI_RXTO | SSI_RXOR);
SSIIntClear(SSI0_BASE , SSI_RXTO | SSI_RXOR);
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
GPIOPinTypeGPIOOutput(GPIO_PORTA_BASE, GPIO_PIN_4);
/* SPI clock & congig */
SSIClockSourceSet(SSI0_BASE , SSI_CLOCK_SYSTEM);
SSIConfigSetExpClk(SSI0_BASE , SysCtlClockGet() , SSI_FRF_MOTO_MODE_0 , SSI_MODE_MASTER , 3000000U , 8U);
SSIEnable(SSI0_BASE);