工程师们你们好,
请问一下,我有一个UART线程来进行UART的读写操作,之后我初始化了一个SPI,增加这个SPI之后,UART的线程无法工作,在CS调试模式下无法标记断点无法进入,但是SPI是可以发送出数据的,在另一块板子上可以收到数据,UART波特率为921600,SPI为1000000,这两个之间会有影响吗?SPI是master模式,这两个同时使用会有问题吗?
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.
工程师们你们好,
请问一下,我有一个UART线程来进行UART的读写操作,之后我初始化了一个SPI,增加这个SPI之后,UART的线程无法工作,在CS调试模式下无法标记断点无法进入,但是SPI是可以发送出数据的,在另一块板子上可以收到数据,UART波特率为921600,SPI为1000000,这两个之间会有影响吗?SPI是master模式,这两个同时使用会有问题吗?
#include <stdint.h>
#include <stddef.h>
#include <SPI_Device.h>
#include "ti/drivers/SPI.h"
#include "ti/drivers/spi/***.h"
#include "ti/drivers/dma/UDMACC26XX.h"
#include "uartdebug.h"
#include "board.h"
#include "string.h"
#define SPI_DATA_LEN 20
SPI_Params SPI_DeviceParam;
SPI_Handle SPI_DeviceHandle;
SPI_Transaction SPI_DeviceTransAct;
char SpiRxBuf[SPI_DATA_LEN];
char SpiTxBuf[SPI_DATA_LEN];
// 中断
void SPI_DeviceCallback (SPI_Handle handle, SPI_Transaction *transaction)
{
UART_Handle uart1 = GetUartHandle();
// Start another transfer
SPI_transfer(handle, transaction);
UART_write(uart1, transaction->rxBuf, 20);
}
// 初始化
void SPI_DeviceInit(void)
{
SPI_init();
SPI_DeviceTransAct.count = SPI_DATA_LEN;
SPI_DeviceTransAct.rxBuf = SpiRxBuf;
SPI_DeviceTransAct.txBuf = SpiTxBuf;
SPI_Params_init(&SPI_DeviceParam);
SPI_DeviceParam.transferMode = SPI_MODE_CALLBACK;
SPI_DeviceParam.mode = SPI_MASTER;
SPI_DeviceParam.frameFormat = SPI_POL1_PHA1;
SPI_DeviceParam.transferCallbackFxn = SPI_DeviceCallback;
SPI_DeviceParam.bitRate = 1000000;
SPI_DeviceHandle = SPI_open(0, &SPI_DeviceParam);
if ( 0 > SPI_control(SPI_DeviceHandle, ***, NULL) )
{
while(1);
}
SPI_transfer(SPI_DeviceHandle, &SPI_DeviceTransAct);
}
// 发送
void SPI_DeviceSendData(void)
{
strncpy(SpiTxBuf, "01234567890123456789", SPI_DATA_LEN);
SPI_transfer(SPI_DeviceHandle, &SPI_DeviceTransAct);
}
您好,以上是我的代码,当做主机发送20个字节,片选引脚配置的是IO11,在从机模式下能够工作,UART也是正常的,主机修改过后则UART不工作,
/* Kick off application - Priority 1 */ SimpleCentral_createTask(); //Uart init UartThread_createTask(); SPI_DeviceInit();
这是main中初始化部分,麻烦您看下,谢谢!
这是我自己给写死了,搞定了!
/*!
* @brief Function to perform SPI transactions
*
* If the SPI is in #SPI_MASTER mode, it will immediately start the
* transaction. If the SPI is in #SPI_SLAVE mode, it prepares the driver for
* a transaction with a SPI master device. The device will then wait until
* the master begins the transfer.
*
* In #SPI_MODE_BLOCKING, #SPI_transfer() will block task execution until the
* transaction has completed or a timeout has occurred.
*
* In #SPI_MODE_CALLBACK, %SPI_transfer() does not block task execution, but
* calls a #SPI_CallbackFxn once the transfer has finished. This makes
* %SPI_tranfer() safe to be used within a Task, software or hardware
* interrupt context. If queued transactions are supported SPI_Transfer may
* be called multiple times to queue multiple transactions. If the driver does
* not support this functionality additional calls will return false. Refer to
* device specific SPI driver documentation for support information.
*
* From calling #SPI_transfer() until transfer completion, the #SPI_Transaction
* structure must stay persistent and must not be altered by application code.
* It is also forbidden to modify the content of the #SPI_Transaction.txBuf
* during a transaction, even though the physical transfer might not have
* started yet. Doing this can result in data corruption. This is especially
* important for slave operations where SPI_transfer() might be called a long
* time before the actual data transfer begins.
*
* @param handle A #SPI_Handle
*
* @param transaction A pointer to a #SPI_Transaction. All of the fields within
* transaction except #SPI_Transaction.count and
* #SPI_Transaction.status are WO (write-only) unless
* otherwise noted in the driver implementations. If a
* transaction timeout has occurred, #SPI_Transaction.count
* will contain the number of frames that were transferred.
* Neither is it allowed to modify the transaction object nor
* the content of #SPI_Transaction.txBuf until the transfer
* has completed.
*
* @return @p true if started successfully; else @p false
*
* @sa #SPI_open
* @sa #SPI_transferCancel
*/
extern bool SPI_transfer(SPI_Handle handle, SPI_Transaction *transaction);