I am using JN5179-001-M16 chipset and I have connected the SPI based flash memory AT25SF161B on JN5179 SPI peripheral, The connected pins are as mentioned below:
DIO0 as a SPI CLK,
DIO7 as a SPI MOSI,
DIO1 as a SPI MISO,
DIO6 as a SPISEL0 (CS)
JN5179 SPI initialization which I have used to verify the SPI communication with flash memory AT25SF161B are as given below which reads the manufacturing information.
void SPI_Init() {
vAHI_SetDIOpinMultiplexValue(0, 1); // DIO0 as SPI CLK
vAHI_SetDIOpinMultiplexValue(7, 1); // DIO7 as SPI MOSI
vAHI_SetDIOpinMultiplexValue(1, 1); // DIO1 as SPI MISO
vAHI_SetDIOpinMultiplexValue(6, 1); // DIO6 as SPISEL0 (CS)
vAHI_SpiConfigure(
1, // Use SPISEL0 (DIO6)
FALSE, // MSB first
FALSE, // Clock Polarity 0 (Mode 0)
FALSE, // Clock Phase 0 (Mode 0)
3, // SPI Clock Divider (1MHz)
FALSE, // Disable SPI Interrupts
TRUE // Enable Auto-CS (Hardware Controls SPISEL0)
);
}
// SPI Transfer Function (Send and Receive a Byte)
uint8 SPI_Transfer(uint8 data) {
vAHI_SpiStartTransfer8(data); // Send 8-bit SPI data
while (bAHI_SpiPollBusy()); // Wait until transfer is complete
return u8AHI_SpiReadTransfer8(); // Read 8-bit SPI response
}
// SPI Send-Only Function (For Commands That Don't Require a Response)
void SPI_SendOnly(uint8 data) {
vAHI_SpiStartTransfer8(data);
while (bAHI_SpiPollBusy()); // Wait until transfer is complete
}
void SPI_ReadManufacturingID() {
uint8 manufacturer_id, memory_type, capacity;
DBG_vPrintf(TRUE,"Sending JEDEC ID Read Command (0x9F)...\n");
SPI_SendOnly(0x9F); // Send Read JEDEC ID Command
DBG_vPrintf(TRUE,"Reading Manufacturer ID...\n");
manufacturer_id = SPI_Transfer(0xFF); // Read Manufacturer ID
memory_type = SPI_Transfer(0xFF); // Read Memory Type
capacity = SPI_Transfer(0xFF); // Read Capacity
DBG_vPrintf(TRUE,"Manufacturer ID: 0x%x\n", manufacturer_id);
DBG_vPrintf(TRUE,"Memory Type: 0x%x\n", memory_type);
DBG_vPrintf(TRUE,"Capacity: 0x%x\n", capacity);
}
The issue is that I could not able to get the CS line is getting low. Can you please let me know the issue with initialization?
Hi
Are you using an application note or example by NXP for your application?
I would recommend checking the Chapter 14 and 15 in JN517x Integrated Peripherals API User Guide.
Here is a link for it JN517x Integrated Peripherals API User Guide
Best Regards
Thank you for the reply, I am following the same document and I can able run the SPI communication successfully after configuring in manual chip select control mode.
Thanks
Rajani Sureja