QSPI Clock inversion

cancel
Showing results for 
Search instead for 
Did you mean: 

QSPI Clock inversion

Jump to solution
1,499 Views
CarlFST60L
Senior Contributor II
Has anyone inverted the QSPI clock in software before? My application calls for it and I cannot find an options in the QSPI.h.
0 Kudos
1 Solution
361 Views
CarlFST60L
Senior Contributor II

I found the answer, you have to use the IO_IOCTL_QSPI_SET_TRANSFER_MODE.

 

Message Edited by CarlFST60L on 2009-07-17 02:09 AM

View solution in original post

0 Kudos
4 Replies
361 Views
EAI
Contributor IV

Try setting the transfer mode:

 

/*
** QSPI Transfer modes
*/
#define QSPI_TRANSFER_MODE_1    1  // Active low; QSPI_CLK transitions middle of bit timing
#define QSPI_TRANSFER_MODE_2 2  // Active high; QSPI_CLK transitions middle of bit timing
#define QSPI_TRANSFER_MODE_3 3  // Active low; QSPI_CLK transitions begining of bit timing
#define QSPI_TRANSFER_MODE_4    4  // Active high; QSPI_CLK transitions begining of bit timing

0 Kudos
361 Views
CarlFST60L
Senior Contributor II

This is clearly the wrong way of modifiying the transfer modes, whats the correct way?

 

How do I find out exactly how to set / clear all the bits in the qspi header? Obviously most of them are not flags as they overlap, so there must be various ways of setting those bits... I know if I wrote the header file i would say how each bit is actually used (although I am sure its obvious to some)...

 

 

Pa

...
 //Open SPI
  SPI_fd = fopen(SLIC_SPI_PORT, (pointer)(QSPI_DEVICE_MASTER_MODE));
  if (SPI_fd == NULL)
  {
    printf("\n Failed to open the SPI Controller: QSPI ALLOCATION ERROR....");
   return FALSE;
  }

  // Set QSPI Baud rate
  param = 4000000;
  printf ("\nChanging the Baud frequency to 4000000Hz...");
  ioctl(SPI_fd, IO_IOCTL_SERIAL_SET_BAUD, &param);  

  //Show Baud rate setting
  ioctl(SPI_fd, IO_IOCTL_SERIAL_GET_BAUD, &param);
  printf (" QSPI freq is no %dHz.\n", param);
 
  //Get the current flags
  param = 0;
  ioctl(SPI_fd, IO_IOCTL_GET_FLAGS, &param);
  printf("IO_CTLFLAGS = %X\n", param); //param = 0x21B
 
  //Mask out any current transfer modes (As it turns out MASTER_MODE has bit 0 and 1 set which are the transfer mode bits
  param &= (~(QSPI_TRANSFER_MODE_1 | QSPI_TRANSFER_MODE_2 | QSPI_TRANSFER_MODE_3 | QSPI_TRANSFER_MODE_4));
  printf("Param with no modes = %X\n", param); //Param 0x218
  param |= (QSPI_TRANSFER_MODE_1);     //Tried this with _1, _2, _3 and 4, and nothing changes   
  printf("Param single = %X\n", param);   //Param 0x219
  ioctl(SPI_fd, IO_IOCTL_SET_FLAGS, &param);
 
  //Read out the Paramters to make sure they are what we expect
  param = 0;
  ioctl(SPI_fd, IO_IOCTL_GET_FLAGS, &param);
  printf("IO_CTLFLAGS returned = %X\n", param); //PAram 0x219

 //This line needs to spit data out with CS asserted to reset the slaves SPI state machine!
  if(write(SPI_fd, &byte, 1) == IO_ERROR) printf("\nERROR: QSPI WRITE FAILED in SPI_Init.\n");
.. 

 

 

Thanks in advance

Carl

Message Edited by CarlFST60L on 2009-07-17 01:04 AM
0 Kudos
361 Views
CarlFST60L
Senior Contributor II
I am also a little confused why the MQX3.2 QSPI example sets / clears the chip select as this is done automatically. Its actually MUCH slower to manually set / clear the CS.
0 Kudos
362 Views
CarlFST60L
Senior Contributor II

I found the answer, you have to use the IO_IOCTL_QSPI_SET_TRANSFER_MODE.

 

Message Edited by CarlFST60L on 2009-07-17 02:09 AM
0 Kudos