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.

LAUNCHXL-F28379D: SPIA没有波形输出

Part Number: LAUNCHXL-F28379D
Other Parts Discussed in Thread: C2000WARE

使用GPIO58~61作为SPIA的GPIO 没有用FIFO也没有用中断 GPIO58也就是SIMO一直没有发送数据 用C2000的例程直接连CLK的波形都没有了

GPIO58~61都用来点过灯 连接都是正常的

望大佬们指点

代码配置如下:

void SPI_Init(void)
{
    //GPIO58
    GpioCtrlRegs.GPBGMUX2.bit.GPIO58=3;
    GpioCtrlRegs.GPBMUX2.bit.GPIO58=3;
    GpioCtrlRegs.GPBDIR.bit.GPIO58=1;
    GpioCtrlRegs.GPBPUD.bit.GPIO58=0;
    GpioCtrlRegs.GPBODR.bit.GPIO58=1;
    //GPIO59
    GpioCtrlRegs.GPBGMUX2.bit.GPIO59=3;
    GpioCtrlRegs.GPBMUX2.bit.GPIO59=3;
    GpioCtrlRegs.GPBDIR.bit.GPIO59=0;
    GpioCtrlRegs.GPBPUD.bit.GPIO59=0;
    //GPIO60
    GpioCtrlRegs.GPBGMUX2.bit.GPIO60=3;
    GpioCtrlRegs.GPBMUX2.bit.GPIO60=3;
    GpioCtrlRegs.GPBDIR.bit.GPIO60=1;
    GpioCtrlRegs.GPBPUD.bit.GPIO60=0;
    GpioCtrlRegs.GPBODR.bit.GPIO60=1;
    //GPIO61
    GpioCtrlRegs.GPBGMUX2.bit.GPIO61=3;
    GpioCtrlRegs.GPBMUX2.bit.GPIO61=3;
    GpioCtrlRegs.GPBDIR.bit.GPIO61=1;
    GpioCtrlRegs.GPBPUD.bit.GPIO61=0;
    GpioCtrlRegs.GPBODR.bit.GPIO61=1;


    SpiaRegs.SPICCR.bit.SPISWRESET=0;
    SpiaRegs.SPICCR.bit.CLKPOLARITY=0;
    SpiaRegs.SPICCR.bit.SPICHAR=7;
    SpiaRegs.SPICTL.bit.CLK_PHASE=0;
    SpiaRegs.SPICTL.bit.MASTER_SLAVE=1;
    SpiaRegs.SPICTL.bit.TALK=1;
    SpiaRegs.SPIBRR.bit.SPI_BIT_RATE=99;
    SpiaRegs.SPICCR.bit.SPISWRESET=1;

}

unsigned char SPI_WriteRead(unsigned char in)
{
    SpiaRegs.SPITXBUF=in;
    while(SpiaRegs.SPISTS.bit.INT_FLAG!=1);
    return SpiaRegs.SPIRXBUF;
}
void main(void)
{
//
// Step 1. Initialize System Control:
// PLL, WatchDog, enable Peripheral Clocks
// This example function is found in the F2837xD_SysCtrl.c file.
//
   InitSysCtrl();

#ifdef _STANDALONE
#ifdef _FLASH
//
// Send boot command to allow the CPU2 application to begin execution
//
IPCBootCPU2(C1C2_BROM_BOOTMODE_BOOT_FROM_FLASH);
#else
//
// Send boot command to allow the CPU2 application to begin execution
//
IPCBootCPU2(C1C2_BROM_BOOTMODE_BOOT_FROM_RAM);
#endif
#endif

//
// Call Flash Initialization to setup flash waitstates
// This function must reside in RAM
//
#ifdef _FLASH
   InitFlash();
#endif

//
// Step 2. Initialize GPIO:
// This example function is found in the F2837xD_Gpio.c file and
// illustrates how to set the GPIO to it's default state.
//
    InitGpio(); // Skipped for this example
    InitPieCtrl();
    InitPieVectTable();
    EALLOW;
//    SCIB_GPIO18_GPIO19_Init();
//    PWM_Init();
    SPI_Init();

//
// TODO Add code to allow configuration of GPADIR from CPU02 using IPC
//
    EDIS;


//
// Step 3. Clear all interrupts and initialize PIE vector table:
// Disable CPU interrupts
//
    DINT;

//
// Initialize the PIE control registers to their default state.
// The default state is all PIE interrupts disabled and flags
// are cleared.
// This function is found in the F2837xD_PieCtrl.c file.
//
//    InitPieCtrl();

//
// Disable CPU interrupts and clear all CPU interrupt flags:
//
//    IER = 0x100;
    IER = 0x0000;
//    IFR = 0x0000;

//
// Initialize the PIE vector table with pointers to the shell Interrupt
// Service Routines (ISR).
// This will populate the entire table, even if the interrupt
// is not used in this example.  This is useful for debug purposes.
// The shell ISR routines are found in F2837xD_DefaultIsr.c.
// This function is found in F2837xD_PieVect.c.
//
//    InitPieVectTable();

//
// Enable global Interrupts and higher priority real-time debug events:
//
    EINT;  // Enable Global interrupt INTM
    ERTM;  // Enable Global realtime interrupt DBGM
    char temp[6],i;
//
// Step 6. IDLE loop. Just sit and loop forever (optional):
    for(;;)
    {
        DELAY_US(1000);
        GpioDataRegs.GPBCLEAR.bit.GPIO61=1;
        SPI_WriteRead(0x02|0x80);
        for(i=0;i<6;i++)
        {
            temp[i]=SPI_WriteRead(0xff);
        }
        GpioDataRegs.GPBSET.bit.GPIO61=1;
    }
}

  • 你好,请问你是使用的官方的评估板,测试的官方例程吗?例程中只是修改了GPIO引脚的配置,其他有没有修改?

  • 是评估板 C2000LaunchPad XL TMS28379D VER:2.0

    跑的例程是C2000Ware_4_00_00_00\device_support\f2837xd\examples\cpu1里面的spi_loopback_interrupts和spi_loopback_dma还有spi_loopback

    spi_loopback_interrupts和spi_loopback_dma的直接连SCLK引脚都没有波形,spi_loopback的SCLK引脚有波形 但是板子上的MOSI引脚没有引出来

    我把spi_loopback例程里面的GPIO配成我用的58~61 MOSI引脚依旧没波形

    还有 中文论坛的活跃度是不是很低 一天才一个回答

  • 你好,如果你用的是这两个例程的话确实是没有外部信号的,因为这两个例程是loopback回环模式。

    如果你想测量外部信号的话可以用这个路径:C:\ti\c2000\C2000Ware_4_00_00_00\driverlib\f2837xd\examples\cpu1\spi\spi_ex3_external_loopback_fifo_interrupts.c

    不过这个例程是用的库的方式配置的。当然你也可以选择关闭回环模式再测试寄存器方式的例程。

    至于论坛活跃度,你的提问时间是在周日,而且不是在9:00 ~ 18:00之外,既是周末又是非工作时间段。另外,现在C2000论坛确实活跃的工程师很少,还好现在临近春节帖子量比较少,否则真的顾不过来所有帖子。

  • 那个例程我看了下 里面没有配置GPIO 我也就没再尝试了

    输出波形没有的问题找到原因了 TXBUFF左对齐 我把输入数据左移8位解决了 现在的问题是MISO没波形= =

    发现个奇怪的现象 我把MISO引脚配置成开漏 有跟MOSI完全一样的波形输出 我把我接的SPI设备拔了 也是这样 但是不配置成开漏就没波形

    没波形的时候看RXBUFF里面一直是0x01ff 好玄学。。。