Other Parts Discussed in Thread: C2000WARE
SPI通讯读不出寄存器数据,但是从芯片的输出来看,写寄存器2应该是写进去了,下面是我的配置代码
void SPI_Write(uint16_t addr, uint16_t data)
{
uint16_t commandword = ((addr << 11) | data);
HAL_GPIO_WritePin(M_CS_GPIO_Port,M_CS_Pin,GPIO_PIN_RESET);
HAL_SPI_Transmit(&hspi2,(uint8_t *)&commandword,1,20);
HAL_GPIO_WritePin(M_CS_GPIO_Port,M_CS_Pin,GPIO_PIN_SET);
HAL_Delay(5);
}
void SPI_Read(uint16_t addr)
{
HAL_GPIO_WritePin(M_CS_GPIO_Port,M_CS_Pin,GPIO_PIN_RESET);
uint16_t commandword = (0x8000 | (addr << 11));
HAL_SPI_Transmit(&hspi2,(uint8_t *)&commandword,1,20);
//HAL_SPI_Receive(&hspi2,(uint8_t *)&commandword,1,20);
HAL_GPIO_WritePin(M_CS_GPIO_Port,M_CS_Pin,GPIO_PIN_SET);
HAL_Delay(5);
}
SPI_Write(0x03,0x1BFF);
SPI_Write(0x02,0x1052);
SPI_Write(0x03,0x1EFF);
03寄存器的锁应该是默认不需要解锁的,但是写进入02的值似乎和实际输出对不上,而且后面几个电流相关的参数也没有配置
请问一下为什么读不出数据以及应该配置哪些参数