大家好、
我遇到一个问题:无法读取 trf7970的寄存 器、值也是0、MISO 始终为低电平。 写入 cmd:0x03和0x00。
随附图片为 trf7970的 sch。 MCU 为 stm32f030。
如何帮助解决此问题?
谢谢!
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.
您好、Qi、
图片中显示的数据是什么(十六进制值)。
对我来说、它与您在第一个帖子中所写的内容不相关。 (0x03、0x00)
只是为了澄清一些问题。 SPI 数据必须在数据时钟的下降沿有效、并且数据必须 首先发送 MSBit。 (请参阅数据表的第40页)
当发送 诸如 SW Init 命令0x03的直接命令时、位7必须为"1"、因为这标志着一个命令。
要在 SPI 总线上进行初始化, 必须发送0x83 (SW 初始化),0x80 (IDLE)。
当您查看您的时序时、情况是否如此?
此致、
Helfried
您好、 Helfried、
直接命令已将位7设置为1:
void SpiDirectCommand (uint8_t ui8Command)
{
SPI_NSS_SET (0);//启动 SPI 模式
//将地址/命令字位分配设置为命令
ui8Command =(0x80 | ui8Command);//命令
ui8Command =(0x9f & ui8Command);//命令代码
//SPI_SendData8 (SPI1、ui8Command);
SPI1_ReadWriteByte (ui8Command);
SPI_NSS_SET (1);//停止 SPI 模式
}\
图片尝试读取地址00。
我已经检查了初始化波形、没有发现问题。
谢谢!
Qi
init 的代码如下所示:
无效
Trf797xInitialSettings (空)
{
uint8_t pui8ModControl[2];
GPIO_InitTypeDef GPIO_InitStructure;
SPI_NSS_SET (1);
RCC_AHBPeriphClockCmd (RF_ENABLE_CLK、ENABLE);
//将引脚配置为输出推挽模式
GPIO_InitStructure.GPIO_Pin = RF_ENABLE_PIN;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out;
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStructure.GPIO_Pud = GPIO_PUT_NOPULL;
GPIO_Init (RF_ENABLE_PORT、&GPIO_InitStructure);
GPIO_SetBits (RF_ENABLE_PORT、RF_ENABLE_PIN);
pui8ModControl[0]= SOFT_INIT;
Trf797xDirectCommand (pui8ModControl[0]);
pui8ModControl[0]=空闲;
Trf797xDirectCommand (pui8ModControl[0]);
pui8ModControl[0]= TRF797x_MODEG_CONTROL;
pui8ModControl[1]= 0x01;// ASK 100%、无 SYS_CLK 输出
//Trf797xWriteSingle (pui8ModControl);
Trf797xWrite (pui8ModControl[0]、pui8ModControl[1]);
pui8ModControl[0]= TRF797x_NFC_TARGET_LEVEL;
pui8ModControl[1]= 0x00;
//Trf797xWriteSingle (pui8ModControl);
Trf797xWrite (pui8ModControl[0]、pui8ModControl[1]);
pui8ModControl[0]= TRF797x_STATUS_CONTROL;
pui8ModControl[1]= 0x21;//0x20;// 3.3VDC、全功率输出
// pui8Command[1]= 0x30;// 3.3VDC,半功率输出
//Trf797xWriteSingle (pui8Command[0]);
Trf797xWrite (pui8ModControl[0]、pui8ModControl[1]);
pui8ModControl[0]= TRF797x_reguler_control;
pui8ModControl[1]= 0x07;// 3.3VDC、全功率输出
// pui8Command[1]= 0x30;// 3.3VDC,半功率输出
//Trf797xWriteSingle (pui8Command[0]);
Trf797xWrite (pui8ModControl[0]、pui8ModControl[1]);
Trf797x_EXTI_Init();
}