TI各位好:
想使用二片板子做SSI通讯,其中遇到问题。
问题1:当Master没发送SSIDataPut,量测CLK没有讯号。有发送SSIDataPut,才会量测到CLK讯号。这样是否正常?
问题2:当SLAVE未收到CLK,是不是不会工作,因为Debug时,发现程式跑完设定参数完后就停止。
目前我Master程式是在While(1)迴圈內打SSIDataPut,才會有一直有CLK出現。
This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
TI各位好:
想使用二片板子做SSI通讯,其中遇到问题。
问题1:当Master没发送SSIDataPut,量测CLK没有讯号。有发送SSIDataPut,才会量测到CLK讯号。这样是否正常?
问题2:当SLAVE未收到CLK,是不是不会工作,因为Debug时,发现程式跑完设定参数完后就停止。
目前我Master程式是在While(1)迴圈內打SSIDataPut,才會有一直有CLK出現。
您可以看一下 tivaware的安装文件夹内 ti\TivaWare_C_Series-2.1.4.178\driverlib 以及 C:\ti\TivaWare_C_Series-2.1.4.178\examples\peripherals\ssi 内的SSI的驱动
具体连接您可以参考
Clk-Clk
Fss-Fss
Tx-Rx
Rx-Tx
程式内查看Master和Slave接收资料状况,Slave接收Master资料是正确,但Master接收Slave资料是错误。
下图黄色波形是FSS和蓝色波形是Master-RX。
Master和Slave程式如下:
SysCtlPeripheralEnable(SYSCTL_PERIPH_SSI0);
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
GPIOPinConfigure(GPIO_PA2_SSI0CLK);
GPIOPinConfigure(GPIO_PA3_SSI0FSS);
GPIOPinConfigure(GPIO_PA4_SSI0RX);
GPIOPinConfigure(GPIO_PA5_SSI0TX);
GPIOPinTypeSSI(GPIO_PORTA_BASE, GPIO_PIN_5 | GPIO_PIN_4 | GPIO_PIN_3 |GPIO_PIN_2);
while(!SysCtlPeripheralReady(SYSCTL_PERIPH_SSI0))
{
}
SSIConfigSetExpClk(SSI0_BASE, SysCtlClockGet(), SSI_FRF_MOTO_MODE_0,
SSI_MODE_MASTER ,500000, 8);
//SSIConfigSetExpClk(SSI0_BASE, SysCtlClockGet(), SSI_FRF_MOTO_MODE_0,
//SSI_MODE_SLAVE,500000, 8);
SSIEnable(SSI0_BASE);
IntEnable(INT_SSI0);
while(1)
{
for(ui32Index = 0; ui32Index <5; ui32Index++)
{
SSIDataPut(SSI0_BASE, pui32DataTx[ui32Index]);
SSIDataGet(SSI0_BASE, &pui32DataRx[ui32Index]);
}
while(SSIBusy(SSI0_BASE))
{
}
}
建议您在将
for(ui32Index = 0; ui32Index <5; ui32Index++)
{
SSIDataPut(SSI0_BASE, pui32DataTx[ui32Index]);
SSIDataGet(SSI0_BASE, &pui32DataRx[ui32Index]);
}
替换为类似下面的代码
//
// Send 3 bytes of data.
//
for(ui32Index = 0; ui32Index < NUM_SSI_DATA; ui32Index++)
{
//
// Display the data that SSI is transferring.
//
UARTprintf("'%c' ", pui32DataTx[ui32Index]);
//
// Send the data using the "blocking" put function. This function
// will wait until there is room in the send FIFO before returning.
// This allows you to assure that all the data you send makes it into
// the send FIFO.
//
SSIDataPut(SSI0_BASE, pui32DataTx[ui32Index]);
}
//
// Wait until SSI0 is done transferring all the data in the transmit FIFO.
//
while(SSIBusy(SSI0_BASE))
{
}
//
// Display indication that the SSI is receiving data.
//
UARTprintf("\nReceived:\n ");
//
// Receive 3 bytes of data.
//
for(ui32Index = 0; ui32Index < NUM_SSI_DATA; ui32Index++)
{
//
// Receive the data using the "blocking" Get function. This function
// will wait until there is data in the receive FIFO before returning.
//
SSIDataGet(SSI0_BASE, &pui32DataRx[ui32Index]);
//
// Since we are using 8-bit data, mask off the MSB.
//
pui32DataRx[ui32Index] &= 0x00FF;
//
// Display the data that SSI0 received.
//
UARTprintf("'%c' ", pui32DataRx[ui32Index]);
}
感谢回覆,后来测试我更改成如下程式,且FSS功能利用GPIO输出H、L去代替。
另外我也做了和Playstation 2 Controller連線控制,也能接收到資料。
while(1)
{
while(SSIDataGetNonBlocking(SSI0_BASE, &pui32DataRx[0]))
{
}
GPIOPinWrite(GPIO_PORTA_BASE, GPIO_PIN_6,~GPIO_PIN_6);
//SysCtlDelay((SysCtlClockGet() / (6500000)));
for(SSI_i = 0; SSI_i<5; SSI_i++)
{
SSIDataPut(SSI0_BASE, pui32DataTx[SSI_i]);
SysCtlDelay((SysCtlClockGet() / (40000)));
}
while(SSIBusy(SSI0_BASE))
{
}
//SysCtlDelay((SysCtlClockGet() / (5000000)));
GPIOPinWrite(GPIO_PORTA_BASE, GPIO_PIN_6,GPIO_PIN_6);
SysCtlDelay((SysCtlClockGet() / (50000)));
for(SSI_j = 0; SSI_j <5; SSI_j++)
{
SSIDataGet(SSI0_BASE, &pui32DataRx[SSI_j]);
pui32DataRx[SSI_j] &= 0x00FF;
}
}