Part Number:CC3220SF-LAUNCHXL
I am trying to interface SPI Communication with MX25L6433F,
CC3220SF has a Master.
Slave - MX25L6433F 8MB Flash
I am not using Board_SPI_MASTER_READY & Board_SPI_SLAVE_READY.
Only using SPI_CS, SPI_MOSI, SPI_MISO, SPI_CLK board mentioning SPI_CS this pin handled automatically (or) i need to handle manually ?
I am tying to read Read Identification(commant 9F) form MX25L6433F it will return manufacturer ID of 1-byte and followed by Device ID of 2-byte but i am not receiving anything ?
/*
* ======== spimaster.c ========
*/
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#include <string.h>
/* POSIX Header files */
#include <pthread.h>
#include <semaphore.h>
#include <unistd.h>
/* Driver Header files */
#include <ti/drivers/GPIO.h>
#include <ti/drivers/SPI.h>
#include <ti/display/Display.h>
/* Example/Board Header files */
#include "Board.h"
#define THREADSTACKSIZE (1024)
#define SPI_MSG_LENGTH (1)
#define MASTER_MSG ("Hello from master, msg#: ")
#define MAX_LOOP (10)
static Display_Handle display;
unsigned char masterRxBuffer[5];
unsigned char masterTxBuffer[SPI_MSG_LENGTH] = {0x9F};
/* Semaphore to block master until slave is ready for transfer */
sem_t masterSem;
* ======== masterThread ========
* Master SPI sends a message to slave while simultaneously receiving a
* message from the slave.
*/
void *masterThread(void *arg0)
{
SPI_Handle masterSpi;
SPI_Params spiParams;
SPI_Transaction transaction;
uint32_t i;
bool transferOK;
int32_t status;
/* Open SPI as master (default) */
SPI_Params_init(&spiParams);
spiParams.frameFormat = SPI_POL0_PHA0;
spiParams.mode = SPI_MASTER;
spiParams.transferMode = SPI_MODE_BLOCKING;
masterSpi = SPI_open(Board_SPI_MASTER, &spiParams);
if (masterSpi == NULL) {
Display_printf(display, 0, 0, "Error initializing master SPI\n");
while (1);
}
else {
Display_printf(display, 0, 0, "Master SPI initialized\n");
}
/* Copy message to transmit buffer */
strncpy((char *) masterTxBuffer, MASTER_MSG, SPI_MSG_LENGTH);
for (i = 0; i < MAX_LOOP; i++) {
/*
* Wait until slave is ready for transfer; slave will pull
* Board_SPI_SLAVE_READY low.
*/
//sem_wait(&masterSem);
/* Initialize master SPI transaction structure */
memset((void *) masterRxBuffer, 0, SPI_MSG_LENGTH);
transaction.count = SPI_MSG_LENGTH;
transaction.txBuf = (void *) masterTxBuffer;
transaction.rxBuf = (void *) masterRxBuffer;
/* Toggle user LED, indicating a SPI transfer is in progress */
GPIO_toggle(Board_GPIO_LED1);
/* Perform SPI transfer */
transferOK = SPI_transfer(masterSpi, &transaction);
if (transferOK) {
Display_printf(display, 0, 0, "Master received: %s", masterRxBuffer);
}
else {
Display_printf(display, 0, 0, "Unsuccessful master SPI transfer");
}
/* Sleep for a bit before starting the next SPI transfer */
sleep(3);
}
SPI_close(masterSpi);
/* Example complete - set pins to a known state */
GPIO_disableInt(Board_SPI_SLAVE_READY);
GPIO_setConfig(Board_SPI_SLAVE_READY, GPIO_CFG_OUTPUT | GPIO_CFG_OUT_LOW);
GPIO_write(Board_SPI_MASTER_READY, 0);
Display_printf(display, 0, 0, "\nDone");
return (NULL);
}
{
.baseAddr = GSPI_BASE,
.intNum = INT_GSPI,
.intPriority = (~0),
.spiPRCM = PRCM_GSPI,
.csControl = SPI_HW_CTRL_CS,
.csPolarity = SPI_CS_ACTIVELOW,
.pinMode = SPI_4PIN_MODE,
.turboMode = SPI_TURBO_OFF,
.scratchBufPtr = &spiCC3220SDMAscratchBuf[CC3220SF_LAUNCHXL_SPI1],
.defaultTxBufValue = 0,
.rxChannelIndex = UDMA_CH6_GSPI_RX,
.txChannelIndex = UDMA_CH7_GSPI_TX,
.minDmaTransferSize = 10,
.mosiPin = SPICC32XXDMA_PIN_07_MOSI,
.misoPin = SPICC32XXDMA_PIN_06_MISO,
.clkPin = SPICC32XXDMA_PIN_05_CLK,
.csPin = SPICC32XXDMA_PIN_08_CS
}
Why i am not able to read and write where i makes mistake ?
Thank You
Vasu