AnsweredAssumed Answered

DSPI Master Transfer in KSDK 2.0?

Question asked by Kenneth Moore on Sep 8, 2016
Latest reply on Sep 9, 2016 by Kenneth Moore

Hello, I was wondering if anyone else had run into this kind of issue working the DSPI_MasterTransferBlocking function in the latest version of the KSDK. I am working on with a SPI EEPROM chip and a MK22FN512VLL12, essentially I have a function that accepts a pointer to a struct, the size of that struct in bytes, and the starting location in EEPROM to write to.

 

uint8_t read_eeprom( void *setup, uint16_t size, uint16_t addr)

 

The DSPI_MasterTransferBlocking function needs the SPI_Type pointer and a pointer to the dspi_transfer_t struct. This struct is created in the following fashion.

 

dspi_transfer_t eeprom_command;

eeprom_command.txData = (uint8_t *) calloc(200, sizeof(uint8_t));

eeprom_command.rxData = (uint8_t *) calloc(200, sizeof(uint8_t));

 

Next, I populate the eeprom transfer data (txData) with the contents of the read command and the address.

 

eeprom_command.txData[0] = 0x03; //read command

eeprom_command.txData[1] = (uint8_t) (addr >> 8);

eeprom_command.txData[2] = (uint8_t) (addr & 0x00FF);

 

Now here's where I have my first question, the dataSize field in the dspi_transfer_t struct. I assume this pertains to both the transfer data and the received data. Or does this field only for the txData length?

 

eeprom_command.dataSize = size + 3? or just 3? 

 

Next is the configFlags field, set this to (kDSPI_MasterCtar1 | kDSPI_MasterPcs1) based off hardware. Then I enable the EEPROM chip select and send the command.

 

DSPI_MasterTransferBlocking(SPI1, &eeprom_command);

 

However, I read 0xFF in all the rxData locations... I have a KSDK 1.3 version of this code as well, so I used that to write data and used 2.0 to read that data back.

 

Any help is appreciated!

Outcomes