AnsweredAssumed Answered

PN7462AUHN SPIM问题

Question asked by xia s on Mar 23, 2019
Latest reply on Apr 8, 2019 by Kan_Li

操作SPIM外部的FLASH时,会出现死机现象,没有任何反应,程序在运行到phhalSPIM_Transmit时死机,代码如下:

 

#define PH_HW_SPIM_TIMEOUT 0xFFFFFFFFUL
#define PH_HW_SPIM_SLAVE 0
#define PH_HW_SPIM_INIT_CRC 0 /* Flag to initialize internal CRC */
#define PH_HW_SPIM_APPEND_CRC 0 /* Flag to say appending of CRC is to be done for Tx bytes
or not, if 1 then CRC is to be appended else not. */
#define PH_HW_SPIM_CRC_INIT 0 /* Transmit CRC initial value. */
#define PH_HW_SPIM_CRC_OFFSET 0 /* Number of bytes to be skipped for CRC computation. */
#define PH_HW_SPIM_MSB_FIRST 1 /* MSB or LSB selection flag. if true MSB transmitted first. */
#define PH_HW_SPIM_NSSPULSE 1 /* NSS pulse control. If false no pulse is generated between the bytes. */
#define PH_HW_SPIM_NSSPOL 0 /* NSS polarity control. If false the polarity is low. */
#define PH_HW_SPIM_MODE 0x00 /**< Mode = 0 CPOL = 0 CPHA = 0 */
#define PH_HW_SPIM_BAUDRATE 0x06 /** b110 5.42MHz */

 

 

phStatus_t eStatus = PH_ERR_SUCCESS;
uint8_t cBuffer[32]={0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0A,0x0B,0x0C,0x0D,0x0E,0x0F,\
0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17,0x18,0x19,0x1A,0x1B,0x1C,0x1D,0x1E,0x1F};
uint16_t wLength;

 

/** Init and Configure SPIM as Egress communication channel */
PH_USER_ASSERT(phhalSPIM_Init(PH_HW_SPIM_TIMEOUT) == PH_ERR_SUCCESS);

PH_USER_ASSERT(
phhalSPIM_Configure(PH_HW_SPIM_SLAVE, PH_HW_SPIM_MSB_FIRST, \
PH_HW_SPIM_MODE, PH_HW_SPIM_BAUDRATE, \
PH_HW_SPIM_NSSPULSE, PH_HW_SPIM_NSSPOL) == PH_ERR_SUCCESS);

cBuffer[0] = 0x4B;
wLength = 1;
eStatus = phhalSPIM_Transmit(PH_HW_SPIM_SLAVE,\
PH_HW_SPIM_INIT_CRC, \
PH_HW_SPIM_APPEND_CRC,\
PH_HW_SPIM_CRC_INIT, \
wLength, cBuffer, \
PH_HW_SPIM_CRC_OFFSET);

wLength = 5;
eStatus = phhalSPIM_Receive(PH_HW_SPIM_SLAVE, \
PH_HW_SPIM_INIT_CRC, \
PH_HW_SPIM_CRC_INIT, \
wLength,cBuffer, \
PH_HW_SPIM_CRC_OFFSET);

 

我看了一个PN7462BM开发板的连接,是用GPIO_1去连接到FLASH的NSS片选信号,我用的是PN7462的SPIM_SSN去连接SPI Flash,型号为W25Q32FVSSIG,读Flash ID的命令都无法发出,请问是什么问题?

 

以前用过LPC的SPI,发现SPI的NSS片选信号不是太好用,难道NXP官方也发现了这个问题,在其PN7462BM开发板上未连接SPIM_SSN,而是用GPIO1作为SPI FLASH的片选信号(SSN)?

 

能否给出一个详细的例程?

Outcomes