cancel
Showing results for 
Search instead for 
Did you mean: 

M95M04-DR - Always reading 0

GSaw
Associate II

I'm trying to interface M95M04-DR with XMC4700. 

When I read RDSR, I receive all 0s.

When I write to an address, again I get all 0s on that address. I'm attaching SPI configuration and code snippet please look help me to solve this issue.

I've connected hold and write protect as high with digital output.

Vcc is 5V.

 

 

 

 

  uint8_t data_rec[8] = {1, 1, 1, 1, 1, 1, 1, 1};
  uint8_t mem_addr[3] = {0x01, 0x00, 0x00};
  uint8_t data_tr = 0x05;

  DIGITAL_IO_SetOutputHigh(&DIGITAL_IO_0); //CS
  DIGITAL_IO_SetOutputHigh(&DIGITAL_IO_1); //Hold
  DIGITAL_IO_SetOutputHigh(&DIGITAL_IO_2); //Write protect

  //write enable

  DIGITAL_IO_SetOutputLow(&DIGITAL_IO_0);

  SPI_MASTER_Transmit(&SPI_MASTER_0, (uint8_t *)&write_en, 1);
  while(SPI_MASTER_0.runtime->tx_busy);

  DIGITAL_IO_SetOutputHigh(&DIGITAL_IO_0);

//some delay

  //write data to address
  DIGITAL_IO_SetOutputLow(&DIGITAL_IO_0);

  SPI_MASTER_Transmit(&SPI_MASTER_0, (uint8_t *)&write_mem, 1);
  SPI_MASTER_Transmit(&SPI_MASTER_0, (uint8_t *)&mem_addr, 3);
  SPI_MASTER_Transmit(&SPI_MASTER_0, (uint8_t *)&data_tr, 1);

  DIGITAL_IO_SetOutputHigh(&DIGITAL_IO_0);

  /* Placeholder for user application code. The while loop below can be replaced with user application code. */
  while(1U)
  {
	  if(timer_count > 50)
	  {
		  DIGITAL_IO_SetOutputLow(&DIGITAL_IO_0);

		  SPI_MASTER_Transmit(&SPI_MASTER_0, (uint8_t *)&read_mem, 1);
		  SPI_MASTER_Transmit(&SPI_MASTER_0, (uint8_t *)&mem_addr, 3);
		  SPI_MASTER_Receive(&SPI_MASTER_0, (uint8_t *)&data_rec, 8);

//		  SPI_MASTER_Transfer(&SPI_MASTER_0, (uint8_t *)&mem_addr, (uint8_t *)&data_rec, 3);

		  DIGITAL_IO_SetOutputHigh(&DIGITAL_IO_0);

		  timer_count = 0;
	  }
  }

 

 

 

 

0 REPLIES 0