测试官网提供的spi示例(mcspiFlash),发现不能够正常运行。然后我为了方便调试,将主程序修改为连续读ID命令(9F)。起初测试时,发现SPID0官角无输出,通过查询论坛上相关内容,可能是管角方向的配制问题,然后我修改了管角方向,用示波器查看,发现SPID0有输出,并且为9F,但是去测SPID1时,发现没有任何输入。找了很久,仍然没有查到可能的问题在哪里。
说明:使用的是自己板子,4个管角连接是am335x默认SPI功能管脚一样。flash的工作电压测了是3.3V。
int main(void)
{
volatile unsigned int count = 0x0FFFu;
unsigned int retVal = FALSE;
unsigned char choice = 0;
unsigned int i ;
/* Enable the clocks for McSPI0 module.*/
McSPI0ModuleClkConfig();
/* Perform Pin-Muxing for SPI0 Instance */
McSPIPinMuxSetup(0);
/* Perform Pin-Muxing for CS0 of SPI0 Instance */
McSPI0CSPinMuxSetup(chNum);
/* Initialize the UART utility functions */
//UARTStdioInit();
//UARTPuts("Here the McSPI controller on the SoC communicates with", -1);
//UARTPuts(" the SPI Flash.\r\n\r\n", -1);
/* Enable IRQ in CPSR.*/
IntMasterIRQEnable();
/* Map McSPI Interrupts to AINTC */
McSPI0AintcConfigure();
/* Do the necessary set up configurations for McSPI.*/
McSPISetUp();
while(1){
for(i = 0 ; i < 0xff ; i++)
;
ReadId() ;
}
}
static void ReadId(void)
{
//unsigned int retVal = FALSE;
txBuffer[0] = 0x9F ;;
length = 1 ;
McSPITransfer();
}
将McSPISetUp配制作如下修改
static void McSPISetUp(void){
...
McSPIMasterModeConfig(SOC_SPI_0_REGS, MCSPI_SINGLE_CH,
MCSPI_TX_RX_MODE, MCSPI_DATA_LINE_COMM_MODE_6,//MCSPI_DATA_LINE_COMM_MODE_1
chNum);
...
}