主题中讨论的其他器件:C2000WARE
我已经为8深度缓冲器配置了 SCI 模式下的 LINB、如下所示:
void LINB_configureSCIMode()
{
//
// Enter LIN reset state to perform configurations
//
LIN_enterSoftwareReset(LINB_BASE);
//
// Switch LIN into SCI mode
//
LIN_enableSCIMode(LINB_BASE);
//
// Set the SCI communication mode to idle line
//
LIN_setSCICommMode(LINB_BASE, LIN_COMM_SCI_IDLELINE);
//
// Set SCI to transmit one stop bit
//
LIN_setSCIStopBits(LINB_BASE,LIN_SCI_STOP_ONE);
//Setting baud rate to 115200
LIN_setBaudRatePrescaler(LINB_BASE,53,4);
//
// Disable parity check
//
LIN_disableSCIParity(LINB_BASE);
//
// Enable multi-buffer mode
//
LIN_enableMultibufferMode(LINB_BASE);
//Enable Receive Data Transfer.
LIN_enableDataReceiver(LINB_BASE);
//
// Module set to complete operations when halted by debugger
//
LIN_setDebugSuspendMode(LINB_BASE, LIN_DEBUG_COMPLETE);
//
// Set character length as 8-bits
//
LIN_setSCICharLength(LINB_BASE, 8);
//
// Set to 1 character in response field
//
LIN_setSCIFrameLength(LINB_BASE, 8);
//
// Disable Internal Loopback mode
//
LIN_disableIntLoopback(LINB_BASE);
//
// Disable interrupt for when a frame has been completely received
//
LIN_enableSCIInterrupt(LINB_BASE, LIN_SCI_INT_RX);
//
// Set the interrupt priority to line 0 (high)
//
LIN_setSCIInterruptLevel0(LINB_BASE, LIN_SCI_INT_RX);
//
// Exit LIN reset state
//
LIN_exitSoftwareReset(LINB_BASE);
}
以下代码用于从接收到的缓冲区中读取8个字节:
if (LIN_isSCIDataAvailable(LINB_BASE))
{
char rx_buffer[10];
int i = 0;
for (i = 0; i < 8; i++) //buffer is 8 byte deep
{
rx_buffer[i] = LIN_readSCICharNonBlocking(LINB_BASE, false);
}
}
但是、当我打印 RX_buffer 的内容时、将为所有索引打印最后接收到的字符的值。 请告诉我出错了。