共2条
1/1 1 跳转至页
SPI 大家看看这个SPI程序为什么不能收
问
void AT91F_SPI_Cfg_spi(void)
{
//* Reset the SPI
AT91F_SPI_Reset(AT91C_BASE_SPI);
//* Configure SPI in Master Mode with No CS selected !!!
AT91F_SPI_CfgMode(AT91C_BASE_SPI, AT91C_SPI_MSTR | AT91C_SPI_MODFDIS | AT91C_SPI_FDIV);
//* Configure SPI CS0 for Serial DataFlash AT45DBxx
AT91F_SPI_CfgCs(AT91C_BASE_SPI,0,spi_mode1);
//* Configure SPI CS3 for DataFlash Card AT45DCBxx
//AT91F_SPI_CfgCs(3, AT91C_SPI_CPOL | (AT91C_SPI_DLYBS & 0x100000) | ((MASTER_CLOCK / (2*DATAFLASH_CLK)) << 8));
//* Enable the SPI
AT91F_SPI_Enable(AT91C_BASE_SPI);
}
////////read spi to confirm if the data oxf5 witen in fm25l256
void read_spi(void)
{
unsigned int readint;
AT91F_SPI_Cfg_spi();
AT91C_BASE_SPI->SPI_TDR = 0x000E0003;
AT91C_BASE_SPI->SPI_TDR = 0x000E0000;
AT91C_BASE_SPI->SPI_TDR = 0x000E0000;
readint=AT91C_BASE_SPI->SPI_RDR;
readint=AT91C_BASE_SPI->SPI_RDR;
readint=AT91C_BASE_SPI->SPI_RDR;
if(readint&0xff<5){
AT91F_PIO_ClearOutput( AT91C_BASE_PIOA, LED4 );
delay();
delay();
delay();
delay();
delay();
delay();
AT91F_PIO_SetOutput( AT91C_BASE_PIOA, LED4 );
}
}
void WRITE_SPI(void)
{
AT91C_BASE_SPI->SPI_TDR = 0X000EFFFF&SPI_D6;
AT91C_BASE_SPI->SPI_TDR = ((unsigned int) 0x000E0002);
AT91C_BASE_SPI->SPI_TDR = (unsigned int)0x000E0000;
AT91C_BASE_SPI->SPI_TDR = (unsigned int)0x000E0000;
AT91C_BASE_SPI->SPI_TDR = (unsigned int)0x000E0002;
AT91C_BASE_SPI->SPI_TDR = (unsigned int)0x000E0003;
AT91C_BASE_SPI->SPI_TDR = (unsigned int)0x010E0004;
//write oxf5 in the address of 0x0;
read_spi();
}
void spi_init(void)
{
AT91F_PIO_CfgPeriph(AT91C_BASE_PIOA, AT91C_PIO_PA11|AT91C_PIO_PA12|AT91C_PIO_PA13|AT91C_PIO_PA14, 0);
AT91F_PMC_EnablePeriphClock ( AT91C_BASE_PMC, (unsigned int) 1<<AT91C_ID_SPI );
AT91F_SPI_Cfg_spi();
//AT91PS_SPI SPI_PT;
//SPI_PT = AT91C_BASE_SPI;
//AT91C_SPI_MR = AT91C_SPI_MSTR|AT91C_SPI_FDIV|AT91C_SPI_MODFDIS;
//AT91F_SPI_CfgMode(AT91C_BASE_SPI,AT91C_SPI_MSTR|AT91C_SPI_FDIV|AT91C_SPI_MODFDIS);
//AT91C_BASE_SPI->SPI_IDR = (unsigned int)0X000003FF;
//AT91C_BASE_SPI->SPI_CSR[0] = (unsigned int) 0X0307FF00;
//OPEN SPI
//AT91C_BASE_SPI->SPI_CR=AT91C_SPI_SPIEN;
WRITE_SPI( );
}
用的时at91sam7s64,在AXD下调试,调试的时候发现通过示波器可以看到输出的波形,但是在读取的时候MISO引脚上没有反应,此时PCS和SPCK引脚也没有波形, 有做过的高手指点一下,究竟是什么问题。不胜感激!!!!!!!!!!!!!!!! 答 1: 请教高手 答 2: 帮你顶rt
{
//* Reset the SPI
AT91F_SPI_Reset(AT91C_BASE_SPI);
//* Configure SPI in Master Mode with No CS selected !!!
AT91F_SPI_CfgMode(AT91C_BASE_SPI, AT91C_SPI_MSTR | AT91C_SPI_MODFDIS | AT91C_SPI_FDIV);
//* Configure SPI CS0 for Serial DataFlash AT45DBxx
AT91F_SPI_CfgCs(AT91C_BASE_SPI,0,spi_mode1);
//* Configure SPI CS3 for DataFlash Card AT45DCBxx
//AT91F_SPI_CfgCs(3, AT91C_SPI_CPOL | (AT91C_SPI_DLYBS & 0x100000) | ((MASTER_CLOCK / (2*DATAFLASH_CLK)) << 8));
//* Enable the SPI
AT91F_SPI_Enable(AT91C_BASE_SPI);
}
////////read spi to confirm if the data oxf5 witen in fm25l256
void read_spi(void)
{
unsigned int readint;
AT91F_SPI_Cfg_spi();
AT91C_BASE_SPI->SPI_TDR = 0x000E0003;
AT91C_BASE_SPI->SPI_TDR = 0x000E0000;
AT91C_BASE_SPI->SPI_TDR = 0x000E0000;
readint=AT91C_BASE_SPI->SPI_RDR;
readint=AT91C_BASE_SPI->SPI_RDR;
readint=AT91C_BASE_SPI->SPI_RDR;
if(readint&0xff<5){
AT91F_PIO_ClearOutput( AT91C_BASE_PIOA, LED4 );
delay();
delay();
delay();
delay();
delay();
delay();
AT91F_PIO_SetOutput( AT91C_BASE_PIOA, LED4 );
}
}
void WRITE_SPI(void)
{
AT91C_BASE_SPI->SPI_TDR = 0X000EFFFF&SPI_D6;
AT91C_BASE_SPI->SPI_TDR = ((unsigned int) 0x000E0002);
AT91C_BASE_SPI->SPI_TDR = (unsigned int)0x000E0000;
AT91C_BASE_SPI->SPI_TDR = (unsigned int)0x000E0000;
AT91C_BASE_SPI->SPI_TDR = (unsigned int)0x000E0002;
AT91C_BASE_SPI->SPI_TDR = (unsigned int)0x000E0003;
AT91C_BASE_SPI->SPI_TDR = (unsigned int)0x010E0004;
//write oxf5 in the address of 0x0;
read_spi();
}
void spi_init(void)
{
AT91F_PIO_CfgPeriph(AT91C_BASE_PIOA, AT91C_PIO_PA11|AT91C_PIO_PA12|AT91C_PIO_PA13|AT91C_PIO_PA14, 0);
AT91F_PMC_EnablePeriphClock ( AT91C_BASE_PMC, (unsigned int) 1<<AT91C_ID_SPI );
AT91F_SPI_Cfg_spi();
//AT91PS_SPI SPI_PT;
//SPI_PT = AT91C_BASE_SPI;
//AT91C_SPI_MR = AT91C_SPI_MSTR|AT91C_SPI_FDIV|AT91C_SPI_MODFDIS;
//AT91F_SPI_CfgMode(AT91C_BASE_SPI,AT91C_SPI_MSTR|AT91C_SPI_FDIV|AT91C_SPI_MODFDIS);
//AT91C_BASE_SPI->SPI_IDR = (unsigned int)0X000003FF;
//AT91C_BASE_SPI->SPI_CSR[0] = (unsigned int) 0X0307FF00;
//OPEN SPI
//AT91C_BASE_SPI->SPI_CR=AT91C_SPI_SPIEN;
WRITE_SPI( );
}
用的时at91sam7s64,在AXD下调试,调试的时候发现通过示波器可以看到输出的波形,但是在读取的时候MISO引脚上没有反应,此时PCS和SPCK引脚也没有波形, 有做过的高手指点一下,究竟是什么问题。不胜感激!!!!!!!!!!!!!!!! 答 1: 请教高手 答 2: 帮你顶rt
共2条
1/1 1 跳转至页
回复
有奖活动 | |
---|---|
【有奖活动】分享技术经验,兑换京东卡 | |
话不多说,快进群! | |
请大声喊出:我要开发板! | |
【有奖活动】EEPW网站征稿正在进行时,欢迎踊跃投稿啦 | |
奖!发布技术笔记,技术评测贴换取您心仪的礼品 | |
打赏了!打赏了!打赏了! |
打赏帖 | |
---|---|
vscode+cmake搭建雅特力AT32L021开发环境被打赏30分 | |
【换取逻辑分析仪】自制底板并驱动ArduinoNanoRP2040ConnectLCD扩展板被打赏47分 | |
【分享评测,赢取加热台】RISC-V GCC 内嵌汇编使用被打赏38分 | |
【换取逻辑分析仪】-基于ADI单片机MAX78000的简易MP3音乐播放器被打赏48分 | |
我想要一部加热台+树莓派PICO驱动AHT10被打赏38分 | |
【换取逻辑分析仪】-硬件SPI驱动OLED屏幕被打赏36分 | |
换逻辑分析仪+上下拉与多路选择器被打赏29分 | |
Let'sdo第3期任务合集被打赏50分 | |
换逻辑分析仪+Verilog三态门被打赏27分 | |
换逻辑分析仪+Verilog多输出门被打赏24分 |