I am having problems with the chip select line. I need it to be active low and can only get it to work active high. When I set the MCF_QSPI_QWR[CSIV] bit the line doesn't do anything. If I don't set the bit the chip select line works but is active high. I am trying to use an external a-d chip and when I use the cs line as an I/O it is too slow so I need to use the qspi chip select. I also tried another board to make sure it wasn't the chip without any luck. Any help would be great.
Here is my code:
void spi_init()
{
int temp_buff[2];
/* Enable QSPI Pins Primary Functions */
MCF_GPIO_PQSPAR =
MCF_GPIO_PQSPAR_DOUT_DOUT|
MCF_GPIO_PQSPAR_DIN_DIN|
MCF_GPIO_PQSPAR_SCK_SCK|
MCF_GPIO_PQSPAR_CS0_CS0;
MCF_QSPI_QMR = MCF_QSPI_QMR_MSTR
| MCF_QSPI_QMR_CPOL
| MCF_QSPI_QMR_BAUD(3);
MCF_QSPI_QIR = MCF_QSPI_QIR_ABRTL
| MCF_QSPI_QIR_ABRTB
| MCF_QSPI_QIR_WCEFB
| MCF_QSPI_QIR_ABRT
| MCF_QSPI_QIR_WCEF
| MCF_QSPI_QIR_SPIF;
MCF_QSPI_QWR = MCF_QSPI_QWR_NEWQP(0)
| MCF_QSPI_QWR_ENDQP(0)
| MCF_QSPI_QWR_CSIV ; //**//
MCF_QSPI_QDLYR = MCF_QSPI_QDLYR_DTL(1)
| MCF_QSPI_QDLYR_QCD(3) ;
///////////************************//////////////
//command pointer set
MCF_QSPI_QAR = 0x0020;
MCF_QSPI_QDR = 0x4100;
MCF_QSPI_QAR = 0x0000;
MCF_QSPI_QDR = 0x8030;
//start transfer
MCF_QSPI_QDLYR |= MCF_QSPI_QDLYR_SPE;
// wait for transfer to complete
while(!(MCF_QSPI_QIR & MCF_QSPI_QIR_SPIF)) {}
MCF_QSPI_QIR |= MCF_QSPI_QIR_SPIF;
MCF_QSPI_QAR = 0x0010;
temp_buff[0] = MCF_QSPI_QDR & 0x1FFF;
///////////************************//////////////
//command pointer set
MCF_QSPI_QAR = 0x0020;
MCF_QSPI_QDR = 0x4100;
MCF_QSPI_QAR = 0x0000;
MCF_QSPI_QDR = 0xBFE0;
//start transfer
MCF_QSPI_QDLYR |= MCF_QSPI_QDLYR_SPE;
// wait for transfer to complete
while(!(MCF_QSPI_QIR & MCF_QSPI_QIR_SPIF)) {}
MCF_QSPI_QIR |= MCF_QSPI_QIR_SPIF;
MCF_QSPI_QAR = 0x0010;
temp_buff[1] = MCF_QSPI_QDR & 0x1FFF;
}
void a2d_spi()
{
int i = 0;
MCF_QSPI_QAR = 0x0020;
MCF_QSPI_QDR = 0x7100;
MCF_QSPI_QAR = 0x0000;
MCF_QSPI_QDR = 0x0000;
MCF_QSPI_QWR |= MCF_QSPI_QWR_WREN;
MCF_QSPI_QWR &= ~MCF_QSPI_QWR_HALT;
//start transfer
MCF_QSPI_QDLYR |= MCF_QSPI_QDLYR_SPE ;
//
while(1)//i<5000)
{
// wait for transfer to complete
while(!(MCF_QSPI_QIR & MCF_QSPI_QIR_SPIF)) {}
MCF_QSPI_QIR = 0xD00F;
MCF_QSPI_QAR = 0x0010;
data_buff[0/*i++*/ ] = MCF_QSPI_QDR;
}
MCF_QSPI_QWR |= MCF_QSPI_QWR_HALT;
}