The overall description of my problem is like this.I need to communicate master (am335x ) and slave (LM4F230H5QR) on SPI communication.I am using CCS for debugging and programming the slave.And whatever data is comming from master side salve is print that data on thermal printer.Everything is correct on printer firmware except spi configuration.
Master configuration is like this...
slave is connected at SPI0 of master(am335x).
frame format mode-- mode 0,
chip select is active low
Clk rate--3.5 MHZ.
as i checked on oscilloscope that correct data is flowing from master to slave.So interrupt occur on slave side but when i checked data register of slave no data is actually coming, so i am not understanding where is actually problem behind.I think if oscilloscope show data it means problem is in slave side.so i need help to solve this problem.
Slave side configuration....
master is connected to spi1 of slave.And my code is like this.
unsigned int Byte_Count=0;
uint32_t RcvData[20];
unsigned char RcvFlag =0;
main()
{
SysCtlClockSet(SYSCTL_SYSDIV_10 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN | SYSCTL_XTAL_16MHZ);
spi_init();
while(1)
{
switch(RcvFlag)
{
case DATA_CAPTURE:
print_data(); /*This will print data on thermal printer*/
reset_buffer();
}
}
}
spi_init()
{
SysCtlPeripheralEnable(SYSCTL_PERIPH_SSI1);
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);
GPIOPinTypeSSI(GPIO_PORTF_BASE, GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_2 | GPIO_PIN_3);
GPIOPinConfigure(GPIO_PF0_SSI1RX);
GPIOPinConfigure(GPIO_PF1_SSI1TX);
GPIOPinConfigure(GPIO_PF2_SSI1CLK);
GPIOPinConfigure(GPIO_PF3_SSI1FSS);
SysCtlPeripheralReset(SYSCTL_PERIPH_SSI1);
SSIDisable(SSI1_BASE);
SSIConfigSetExpClk(SSI1_BASE , SysCtlClockGet() , SSI_FRF_MOTO_MODE_0 , SSI_MODE_MASTER , 3000000 , 8);
SSIEnable(SSI1_BASE);
SSIIntEnable( SSI1_BASE , SSI_RXFF | SSI_RXOR);
SSIIntRegister(SSI1_BASE , SPI_INTERRUPT_HANDLER);
}
//
// I register interrupt handler in startup_ccs.c
// and interrupt handler is shown below.
//
void SPI_INTERRUPT_HANDLER(void){
unsigned long ulStatus;
ulStatus =SSIIntStatus(SSI1_BASE, true);
SSIIntClear(SSI1_BASE, ulStatus);
while(SSIDataGetNonBlocking(SSI1_BASE, &RcvData[Byte_Count]))
{
Buffer[Byte_Count] = (unsigned char)(RcvData[Byte_Count] & 0x00FF); /* Store Serial Data */
if ( Buffer[Byte_Count] == 0x10 ) { /*0x10 is used for delimiter */
RcvFlag = 2;
SSIIntDisable(SSI1_BASE, SSI_RXFF | SSI_RXOR );
break;
}
Byte_Count++;
if (Byte_Count >= 8) {
RcvFlag = 2; /* Buffer full Set command flag */
SSIIntDisable(SSI1_BASE, SSI_RXFF | SSI_RXOR);
break;
}
}
}
reset_buffer()
{
int l=0;
Byte_Count = 0;
for (l = 0; l < 8; l++){
Buffer[l] = 0x00;
SSIIntEnable( SSI1_BASE , SSI_RXFF | SSI_RXOR);
}