I gave the following example:
MyBuf2->pu16TxData[0] = CNF1;
MyBuf2->pu16TxData[1] = CAN_WRITE;
MyBuf2->pu16TxData[2] = 0x25;
You did this:
MyBuf2->pu16TxData[0] = (CAN_WRITE << 8);
MyBuf2->pu16TxData[1] = (CNF1 << 8);
MyBuf2->pu16TxData[2] = (0x26 << 8);
I provided you with working code in my example. Those shifts are wrong. My manual on the QSPI states:
30.4.1.2 Transmit RAM
... Outbound data must be written to transmit RAM in a
right-justified format. The unused bits are ignored.
You pushed the 8 bit data to the LEFT. It does not need this at all.
> i think shifleft 8bits is needed.Is this right?
You should read the entire QSPI chapter again. That information is in there (in my copy, it should be in yours too). If it isn't in yours, download and read other Coldfire manuals that have QSPIs. Sometimes some manuals are better than others, but most times the chapters on the same peripherals are cut-and-paste identical.
I won't go through the rest of your code, there are too many problems. Rip it up and start again. I would suggest only using one buffer. Fill it in, send a command, fill it in again for the next command, send that an so on.
> // after init buffer
If I can't see the "init buffer" code I can't check to see if it is OK.
> for (j=0; j < sQSPIBuff->u8Size; j++){
There's no code initialising "u8Size". It has to be set to "1" for the first command and "3" for the second one, and so on for commands of different lengths (lengths from 1 to 9 are required).
I would STRONGLY recommend that you connect an oscilloscope to the SPI bus. Then check that the data that you think is going onto the bus is what is actually getting on the bus. If you had done this with your current code you'd have seen that you're always sending zeroes. You can also see what data is being read back from the chip
> set_cs(0);
Don't you have the QSPI CS pins connected to the SPI peripherals? You seem to as you're adding "MCF_QSPI_QDR_CS3" to the command which will drive that chip select during the transfer. So why are you calling a different "set_cs(0)" function?
You're sending (or trying to send) three bytes, but are never setting "pu8Cmd[2]" to anything. The number of commands must match the number of data bytes. And if you're reading data, the number of command bytes must match the whole transfer length (write and read part).
The third command buffer is WRITING to the chip, but you're never sending a READ command to try and read anything back from the chip. Your last paragraph mentions sending a READ. What happens is that you have to send the READ as two bytes (as you say), but you then have to send a THIRD byte (content doesn't matter) to read the data back. The read data will be in the THIRD byte in the read buffer. To read back a whole 8 byte message you have to send a "READ RX BUFFER" instruction and then perform another 8 transfers to get the data read back.
For the READ you should look at this on an oscilloscope and match it with the "FIGURE 12-2: READ INSTRUCTION" diagram in the MCP2515 manual. That shows the instruction, address and the returned data in the next 8 bits.
Like I said, expect this to take weeks or months.
If you don't need the QSPI speed, it might be easier if you can find some working MCP2515 code that uses "bit-bang" SPI and then just drive the SPI pins from software. You want to copy working MCP2515 code and not write it yourself.
Once you have that working you can then convert the SPI functions to ones using the QSPI. It is a lot easier to incrementally modify and improve working code than to write everything from scratch and then have to debug bugs in everything at the same time.
Tom