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; } }