请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。
器件型号:TMS320F28379D 工具与软件:
大家好!
我正在尝试使用带有上述微控制器的非 FIFO 来发送一个简单的16位数据流。 我用两个 F28379D、一个用作控制器、另一个用作 外设。
控制器代码如下:
//
// Included Files
//
#include "driverlib.h"
#include "device.h"
#include "board.h"
#include <stdint.h>
#include <stdio.h>
#define SPIFSI_CLK_SPEED 12500000U
void configureGPIOs(void) {
// GPIO18 is the SPICLKA.
//
GPIO_setMasterCore(60, GPIO_CORE_CPU1);
GPIO_setPinConfig(GPIO_60_SPICLKA);
GPIO_setQualificationMode(60, GPIO_QUAL_ASYNC);
//
// GPIO16 is the SPISIMOA.
//
GPIO_setMasterCore(58, GPIO_CORE_CPU1);
GPIO_setPinConfig(GPIO_58_SPISIMOA);
GPIO_setQualificationMode(58, GPIO_QUAL_ASYNC);
}
//
// Main
//
void main(void)
{
uint16_t sData = 0x0F0F; // Send data
//
// Initialize device clock and peripherals
//
Device_init();
//
// Disable pin locks and enable internal pullups.
//
Device_initGPIO();
//
// Initialize PIE and clear PIE registers. Disables CPU interrupts.
//
Interrupt_initModule();
//
// Initialize the PIE vector table with pointers to the shell Interrupt
// Service Routines (ISR).
//
Interrupt_initVectorTable();
//
// Board initialization
//
Board_init();
configureGPIOs();
//
// Enable Global Interrupt (INTM) and realtime interrupt (DBGM)
//
EINT;
ERTM;
SPI_disableModule(SPIA_BASE); // Disable SPI before configuring
// For baud rate calculations, check pg. 2262 of the Technical Reference Manual
SPI_setConfig(SPIA_BASE, DEVICE_LSPCLK_FREQ, SPI_PROT_POL0PHA0, SPI_MODE_CONTROLLER, SPIFSI_CLK_SPEED, 16);
SPI_enableModule(SPIA_BASE); // Enable SPI on SPIA
// Loop forever. Suspend or place breakpoints to observe the buffers.
while(1) {
// Transmit Data, blocks until buffer is empty
SPI_writeDataBlockingNonFIFO(SPIA_BASE, sData);
}
}
此代码运行良好(我相信)。 我看到它在示波器上发送数据。
但是、我很难使用代码在 F28379D 上接收用作外设的数据。
外设代码如下所示:
#include "driverlib.h"
#include "device.h"
#include "board.h"
#include <stdint.h>
#include <stdio.h>
#define SPIFSI_CLK_SPEED 12500000U
void configureGPIOs(void) {
// GPIO18 is SPICLK
//
GPIO_setMasterCore(18, GPIO_CORE_CPU1);
GPIO_setPinConfig(GPIO_18_SPICLKA);
GPIO_setQualificationMode(18, GPIO_QUAL_ASYNC);
//
// GPIO16 is SPISIMO
//
GPIO_setMasterCore(16, GPIO_CORE_CPU1);
GPIO_setPinConfig(GPIO_16_SPISIMOA);
GPIO_setQualificationMode(16, GPIO_QUAL_ASYNC);
// GPIO19 is SPISTEA
//
GPIO_setMasterCore(19, GPIO_CORE_CPU1);
GPIO_setPinConfig(GPIO_19_SPISTEA);
GPIO_setQualificationMode(19, GPIO_QUAL_ASYNC);
}
//
// Main
//
void main(void)
{
uint16_t rData = 0x0000; // Receive data
//
// Initialize device clock and peripherals
//
Device_init();
//
// Disable pin locks and enable internal pullups.
//
Device_initGPIO();
//
// Initialize PIE and clear PIE registers. Disables CPU interrupts.
//
Interrupt_initModule();
//
// Initialize the PIE vector table with pointers to the shell Interrupt
// Service Routines (ISR).
//
Interrupt_initVectorTable();
//
// Board initialization
//
Board_init();
configureGPIOs();
//
// Enable Global Interrupt (INTM) and realtime interrupt (DBGM)
//
EINT;
ERTM;
SPI_disableModule(SPIA_BASE); // Disable SPI before configuring
// For baud rate calculations, check pg. 2262 of the Technical Reference Manual
SPI_setConfig(SPIA_BASE, DEVICE_LSPCLK_FREQ, SPI_PROT_POL0PHA0, SPI_MODE_PERIPHERAL, SPIFSI_CLK_SPEED, 16);
SPI_enableModule(SPIA_BASE); // Enable SPI on SPIA
// Loop forever. Suspend or place breakpoints to observe the buffers.
while(1) {
// Receive Data, blocks until buffer is empty
rData = SPI_readDataBlockingNonFIFO(SPIA_BASE);
}
}
我无法看到收到任何数据。 我想知道你们中是否有人可以提供帮助。 非常感谢。 谢谢!