AnsweredAssumed Answered

Reading SPI NOR ID using kinetis k70

Question asked by sameerarvikar on Jul 18, 2017
Latest reply on Jul 26, 2017 by Hui_Ma

I am using spi 1 of kinetis k70 (connected to spi nor)

I am trying to read manufacturer id of spi nor ,

For this i have to write "9f" to spi nor and it will written manufacturer id ,but i am able to read the data

I have used the example given in help

and used spi and consoleio components from processor expert

#include "Cpu.h"
#include "Events.h"
#include "SM1.h"
#include "CsIO1.h"
#include "IO1.h"
/* Including shared modules, which are used for whole project */
#include "PE_Types.h"
#include "PE_Error.h"
#include "PE_Const.h"
#include "IO_Map.h"

#define BLOCK_SIZE 4

uint8_t OutData[BLOCK_SIZE] = "9F";

uint8_t InpData[BLOCK_SIZE];
volatile LDD_SPIMASTER_TError ComError = 0U;
LDD_TError Error;
LDD_TDeviceData *MySPIPtr;

int main(void)

{
/*** Processor Expert internal initialization. DON'T REMOVE THIS CODE!!! ***/
PE_low_level_init();
/*** End of Processor Expert internal initialization. ***/


MySPIPtr = SM1_Init(NULL); /* Initialization of SM1 component */

while(1){
SM1_SelectConfiguration(MySPIPtr, 1U, 1U); /* Select chip select 0 and attribute set 0 */
Error = SM1_ReceiveBlock(MySPIPtr, InpData, BLOCK_SIZE); /* Request data block reception */
printf("Receive --> %x\n",InpData);
Error = SM1_SendBlock(MySPIPtr, OutData, BLOCK_SIZE); /* Start transmission/reception */
while (!SM1_GetBlockReceivedStatus(MySPIPtr)) { /* Wait until data block is transmitted/received */
SM1_Main(MySPIPtr);
}

}

#ifdef PEX_RTOS_START
PEX_RTOS_START(); /* Startup of the selected RTOS. Macro is defined by the RTOS component. */
#endif
/*** End of RTOS startup code. ***/
/*** Processor Expert end of main routine. DON'T MODIFY THIS CODE!!! ***/
for(;;){}
/*** Processor Expert end of main routine. DON'T WRITE CODE BELOW!!! ***/
} /*** End of main routine. DO NOT MODIFY THIS TEXT!!! ***/

/* END main */
/*!
** @}
*/
/*
** ###################################################################
**
** This file was created by Processor Expert 10.5 [05.21]
** for the Freescale Kinetis series of microcontrollers.
**
** ###################################################################
*/

So when i print i get Receive --> 1fff00d8

 

which is some wrong value ,ii think i am not reading correctly,what should i change in the program to do it

Outcomes